Forum Moderators: coopster
<?PHP
$InventoryNumber = $_POST['InventoryNumber'];
$Make = $_POST['Make'];
$Model = $_POST['Model'];
$Description = $_POST['Description'];
$Accessories = $_POST['Accessories'];
$SerialNo = $_POST['SerialNo'];
$Comments = $_POST['Comments'];
$NeedsAttention = $_POST['NeedsAttention'];
$PATdate = $_POST['PATdate'];
$Visual = $_POST['Visual'];
$Insulation = $_POST['Insulation'];
$Load = $_POST['Load'];
$Leak = $_POST['Leak'];mysql_connect("localhost", "root", "password") or die(mysql_error());
mysql_select_db("stock_list") or die(mysql_error());mysql_query("INSERT INTO stock_pat (InventoryNumber, Make, Model, Description, Accessories, SerialNo, Comments, NeedsAttention, PATdate, Visual, Insulation, Load, Leak) VALUES ('$InventoryNumber', '$Make', '$Model', '$Description', '$Accessories', '$SerialNo', '$Comments', '$NeedsAttention', '$PATdate', '$Visual', '$Insulation', '$Load', '$Leak');");
echo mysql_error();echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Item Added (PAT)</title>
</head>
<form id="add_pat_item" name="add_pat_item" method="post" action="">
<p><strong><u>Add New Item (PAT)</u></strong></p>
<table width="700" border="0">
<tr>
<td width="200" valign="top">InventoryNo:</td>
<td width="484" valign="top"><input name="InventoryNumber" type="text" disabled="disabled" id="InventoryNumber" value="'.$InventoryNumber.'" /></td>
</tr>
<tr>
<td valign="top">Make:</td>
<td valign="top"><label>
<input name="Make" type="text" disabled="disabled" id="Make" size="50" value="'.$Make.'" />
</label></td>
</tr>
<tr>
<td valign="top">Model:</td>
<td valign="top"><label>
<input name="Model" type="text" disabled="disabled" id="Model" size="50" value="'.$Model.'" />
</label></td>
</tr>
<tr>
<td valign="top">Desctiption:</td>
<td valign="top"><label>
<textarea name="Description" cols="75" rows="3" disabled="disabled" id="Description">'.$Description.'</textarea>
</label></td>
</tr>
<tr>
<td valign="top">Accessories:</td>
<td valign="top"><label>
<input name="Accessories" type="text" disabled="disabled" id="Accessories" size="75" value="'.$Accessories.'" />
</label></td>
</tr>
<tr>
<td valign="top">SerialNo:</td>
<td valign="top"><label>
<input name="SerialNo" type="text" disabled="disabled" id="SerialNo" size="25" value="'.$SerialNo.'" />
</label></td>
</tr>
<tr>
<td valign="top">Comments:</td>
<td valign="top"><label>
<textarea name="Comments" cols="75" rows="5" disabled="disabled" id="Comments">'.$Comments.'</textarea>
</label></td>
</tr>
<tr>
<td valign="top">NeedsAttention:</td>
<td valign="top"><label>
<input name="NeedsAttention" type="text" disabled="disabled" id="NeedsAttention" value="'.$NeedsAttention.'" />
1=needsattention</label></td>
</tr>
<tr>
<td valign="top">PATdate:</td>
<td valign="top"><label>
<input name="PATdate" type="text" disabled="disabled" id="PATdate" size="25" value="'.$PATdate.'" />
</label></td>
</tr>
<tr>
<td valign="top">Visual:</td>
<td valign="top"><label>
<input name="Visual2" type="text" disabled="disabled" id="Visual" value="'.$Visual.'" />
1=pass 0=fail</label></td>
</tr>
<tr>
<td valign="top">Insulation:</td>
<td valign="top"><label>
<input name="Insulation" type="text" disabled="disabled" id="Insulation" value="'.$Insulation.'" />
</label></td>
</tr>
<tr>
<td valign="top">Load:</td>
<td valign="top"><label>
<input name="Load" type="text" disabled="disabled" id="Load" value="'.$Load.'" />
</label></td>
</tr>
<tr>
<td valign="top">Leak</td>
<td valign="top"><label>
<input name="Leak" type="text" disabled="disabled" id="Leak" value="'.$Leak.'" />
</label></td>
</tr>
<tr valign="top">
<td colspan="2" align="center"><a href="new_pat_item.html">Add Another Item</a></td>
</tr>
</table>
<p> </p>
</form>
<body>
</body>
</html>';
?>
it shows the echo form but comes up with this:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Load, Leak) VALUES ('10000', 'Peavy', 'Unity 1002', '12ch mixer', 'Case, IEC lea' at line 1
please help :(
echo "INSERT INTO stock_pat (InventoryNumber, Make, Model, Description, Accessories, SerialNo, Comments, NeedsAttention, PATdate, Visual, Insulation, Load, Leak) VALUES ('$InventoryNumber', '$Make', '$Model', '$Description', '$Accessories', '$SerialNo', '$Comments', '$NeedsAttention', '$PATdate', '$Visual', '$Insulation', '$Load', '$Leak');";
BEFORE executing the query?
This way you cand see if there's something wrong with your SQL instruction.
INSERT INTO stock_pat (InventoryNumber, Make, Model, Description, Accessories, SerialNo, Comments, NeedsAttention, PATdate, Visual, Insulation, Load, Leak) VALUES ('10000', 'Peavy', 'Unity 1002', '12ch mixer', 'Case, IEC lead', '8807220', '', '0', '2009-01-13', '1', '9.9mohm', '0.05kva', '0.30ma');You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Load, Leak) VALUES ('10000', 'Peavy', 'Unity 1002', '12ch mixer', 'Case, IEC lea' at line 1
INSERT INTO stock_pat (`InventoryNumber`, `Make`, `Model`, `Description`, `Accessories`, `SerialNo`, `Comments`, `NeedsAttention`, `PATdate`, `Visual`, `Insulation`, `Load`, `Leak`) VALUES ('$InventoryNumber', '$Make', '$Model', '$Description', '$Accessories', '$SerialNo', '$Comments', '$NeedsAttention', '$PATdate', '$Visual', '$Insulation', '$Load', '$Leak')
LOAD is one of them and, in this case, is confusing MySQL. As mooger35 points out, wrapping variable names with `` gets around the problem and lets you use reserved words as column names. (Although you probably still want to avoid it.)
<?PHP
$InventoryNumber = $_POST['InventoryNumber'];
$Make = $_POST['Make'];
$Model = $_POST['Model'];
$Description = $_POST['Description'];
$Accessories = $_POST['Accessories'];
$SerialNo = $_POST['SerialNo'];
$Comments = $_POST['Comments'];
$NeedsAttention = $_POST['NeedsAttention'];
$PATdate = $_POST['PATdate'];
$Visual = $_POST['Visual'];
$Insulation = $_POST['Insulation'];
$Load = $_POST['Load'];
$Leak = $_POST['Leak'];echo "INSERT INTO stock_pat ('InventoryNumber', 'Make', 'Model', 'Description', 'Accessories', 'SerialNo', 'Comments', 'NeedsAttention', 'PATdate', 'Visual', 'Insulation', 'Load', 'Leak') VALUES ('$InventoryNumber', '$Make', '$Model', '$Description', '$Accessories', '$SerialNo', '$Comments', '$NeedsAttention', '$PATdate', '$Visual', '$Insulation', '$Load', '$Leak');<P>";
mysql_connect("localhost", "root", "password") or die(mysql_error());
mysql_select_db("stock_list") or die(mysql_error());mysql_query("INSERT INTO stock_pat ('InventoryNumber', 'Make', 'Model', 'Description', 'Accessories', 'SerialNo', 'Comments', 'NeedsAttention', 'PATdate', 'Visual', 'Insulation', 'Load', 'Leak') VALUES ('$InventoryNumber', '$Make', '$Model', '$Description', '$Accessories', '$SerialNo', '$Comments', '$NeedsAttention', '$PATdate', '$Visual', '$Insulation', '$Load', '$Leak');");
echo mysql_error();echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Item Added (PAT)</title>
</head>
<form id="add_pat_item" name="add_pat_item" method="post" action="">
<p><strong><u>Add New Item (PAT)</u></strong></p>
<table width="700" border="0">
<tr>
<td width="200" valign="top">InventoryNo:</td>
<td width="484" valign="top"><input name="InventoryNumber" type="text" disabled="disabled" id="InventoryNumber" value="'.$InventoryNumber.'" /></td>
</tr>
<tr>
<td valign="top">Make:</td>
<td valign="top"><label>
<input name="Make" type="text" disabled="disabled" id="Make" size="50" value="'.$Make.'" />
</label></td>
</tr>
<tr>
<td valign="top">Model:</td>
<td valign="top"><label>
<input name="Model" type="text" disabled="disabled" id="Model" size="50" value="'.$Model.'" />
</label></td>
</tr>
<tr>
<td valign="top">Desctiption:</td>
<td valign="top"><label>
<textarea name="Description" cols="75" rows="3" disabled="disabled" id="Description">'.$Description.'</textarea>
</label></td>
</tr>
<tr>
<td valign="top">Accessories:</td>
<td valign="top"><label>
<input name="Accessories" type="text" disabled="disabled" id="Accessories" size="75" value="'.$Accessories.'" />
</label></td>
</tr>
<tr>
<td valign="top">SerialNo:</td>
<td valign="top"><label>
<input name="SerialNo" type="text" disabled="disabled" id="SerialNo" size="25" value="'.$SerialNo.'" />
</label></td>
</tr>
<tr>
<td valign="top">Comments:</td>
<td valign="top"><label>
<textarea name="Comments" cols="75" rows="5" disabled="disabled" id="Comments">'.$Comments.'</textarea>
</label></td>
</tr>
<tr>
<td valign="top">NeedsAttention:</td>
<td valign="top"><label>
<input name="NeedsAttention" type="text" disabled="disabled" id="NeedsAttention" value="'.$NeedsAttention.'" />
1=needsattention</label></td>
</tr>
<tr>
<td valign="top">PATdate:</td>
<td valign="top"><label>
<input name="PATdate" type="text" disabled="disabled" id="PATdate" size="25" value="'.$PATdate.'" />
</label></td>
</tr>
<tr>
<td valign="top">Visual:</td>
<td valign="top"><label>
<input name="Visual2" type="text" disabled="disabled" id="Visual" value="'.$Visual.'" />
1=pass 0=fail</label></td>
</tr>
<tr>
<td valign="top">Insulation:</td>
<td valign="top"><label>
<input name="Insulation" type="text" disabled="disabled" id="Insulation" value="'.$Insulation.'" />
</label></td>
</tr>
<tr>
<td valign="top">Load:</td>
<td valign="top"><label>
<input name="Load" type="text" disabled="disabled" id="Load" value="'.$Load.'" />
</label></td>
</tr>
<tr>
<td valign="top">Leak</td>
<td valign="top"><label>
<input name="Leak" type="text" disabled="disabled" id="Leak" value="'.$Leak.'" />
</label></td>
</tr>
<tr valign="top">
<td colspan="2" align="center"><a href="new_pat_item.html">Add Another Item</a></td>
</tr>
</table>
<p> </p>
</form>
<body>
</body>
</html>';
?>