Hi... am totaly missed up please help me.
i have created a form and want to update this form information the first i display the information in the input fields so that the user can update it(which is working fine) and change it then the information is retrieved from the form and go to a update.php which do the updating ... here is the problem every time i submit the form it gives me this error
You have an error in your SQL syntax near '-volumes = '8', image-name = '',desc = 'Kurosaki, aka Kurosagi (played by Y' at line 2
and here is the form
$host = "localhost";
$user = "";
$password = "";
$db = "store";
$table = "manga";
$conn=mysql_connect($host,$user,$password) or die("Failed to connect");
mysql_select_db($db) or die("Falied to select database");
echo "<table cellpadding=\"0\" cellspacing=\"0\" width=\"348\">
<!-- MSTableType=\"layout\" -->
<tr>
<td height=\"46\">
<p align=\"center\"><font face=\"Aharoni\" color=\"#808000\"><b>Use the form to modify the manga information </b></font></td>
</tr>
</table> ";
// $code = $_POST['name'];
$id = $_GET['id'];
$sql = "SELECT * FROM $table WHERE id = '$id'";
$result = mysql_query($sql);
//if the querey was executd
if ($result){
while ($myrow = mysql_fetch_array($result)){
echo "<form method=\"POST\" enctype=\"multipart/form-data\" action= manga_update.php>
<!--webbot bot=\"FileUpload\" U-File=\"fpweb:/_private/form_results.csv\" S-Format=\"TEXT/CSV\" S-Label-Fields=\"TRUE\" -->
<input type=hidden name=id value=$myrow[id]><p>
<p dir=\"ltr\" align=\"center\"><font face=\"Arial Narrow\"><b><label for=\"fp1\"> Article Code</label></b><input name=\"code\" size=\"20\" id=\"fp1\" value=$myrow[1]></font></p>
<p dir=\"ltr\" align=\"center\"><font face=\"Arial Narrow\"><label for=\"fp2\">
<b> Manga Name: </b> </label><input type=\"text\" name=\"name\" size=\"20\" id=\"fp2\" value=$myrow[2]></font></p>
<p dir=\"ltr\" align=\"center\"><font face=\"Arial Narrow\"><label for=\"fp3\">
<b> Author: </b></label><input type=\"text\" name=\"author\" size=\"20\" id=\"fp3\" value=$myrow[3]></font></p>
<p dir=\"ltr\" align=\"center\"><font face=\"Arial Narrow\"><label for=\"fp4\">
<b>price:</b></label><input type=\"text\" name=\"price\" size=\"20\" id=\"fp4\" value=$myrow[4]></font></p>
<p dir=\"ltr\" align=\"center\"><label for=\"fp5\">
<font face=\"Arial Narrow\"><b> Language:</b> </font> </label>
<font face=\"Arial Narrow\"><input type=\"text\" name=\"language\" size=\"20\" id=\"fp5\" value=$myrow[5]></font></p>
<p dir=\"ltr\" align=\"center\">
<font face=\"Arial Narrow\">
<b>Stock Status:</b>
in stock<b> </b>
<input type=\"radio\" value=\"inStock\" name=\"status\"> back ordered<input type=\"radio\" name=\"status\" value=\"backOrdered\"></font></p>
<p dir=\"ltr\" align=\"center\"><label for=\"fp6\"><font face=\"Arial Narrow\"><b>
Category:</b> </font>
</label><font face=\"Arial Narrow\"><select size=\"1\" name=\"cato\" id=\"fp6\" value=$myrow[7] >
<option selected>$myrow[7]</option>
<option >----------</option>
<option value = \"drama\">drama</option>
<option value=\"comedy\">comedy</option>
<option value=\"romance\">romance</option>
<option value=\"action\">action</option>
<option value=\"horror\">horror</option>
</select></font></p>
<p dir=\"ltr\" align=\"center\"><label for=\"fp7\"><font face=\"Arial Narrow\"><b>number of volumes</b>:<b> </b>
</font>
</label><font face=\"Arial Narrow\"><select size=\"1\" name=\"nvolumes\" id=\"fp7\" value=$myrow[8]>
<option selected>$myrow[8]</option>
<option value=\"1\">1</option>
<option value=\"2\">2</option>
<option value=\"3\">3</option>
<option value=\"4\">4</option>
<option value=\"5\">5</option>
<option value=\"6\">6</option>
<option value=\"7\">7</option>
<option value=\"8\">8</option>
<option value=\"9\">9</option>
<option value=\"10\">10</option>
<option value=\"11\">11</option>
<option value=\"12\">12</option>
<option value=\"13\">13</option>
<option value=\"14\">14</option>
<option value=\"15\">15</option>
<option value=\"16\">16</option>
<option value=\"17\">17</option>
<option value=\"18\">18</option>
<option value=\"19\">19</option>
<option value=\"20\">20</option>
</select></font></p>
<p dir=\"ltr\" align=\"center\"><label for=\"fp8\"><font face=\"Arial Narrow\"><b>
Cover Page</b>: </font></label>
<font face=\"Arial Narrow\">
<input type=\"file\" name=\"form_data\" size=\"20\" id=\"fp8\" value=$myrow[9]></font></p>
<p dir=\"ltr\" align=\"center\"><font face=\"Arial Narrow\"><b>
Description</b>:</font></p>
<p dir=\"ltr\" align=\"center\"><font face=\"Arial Narrow\"><textarea rows=\"10\" name=\"description\" cols=\"42\" value=>$myrow[10]</textarea></font></p>
<p dir=\"ltr\" align=\"center\"><font face=\"Arial Narrow\"><b>Licensed</b> :
<input type=\"checkbox\" name=\"licsd\" value=$myrow[11]><b>Complete:
</b><input type=\"checkbox\" name=\"compl\" value=$myrow[12]></font></p>
<p dir=\"ltr\" align=\"center\"><font face=\"Arial Narrow\"><input type=\"submit\" value=\"Submit\" name=\"B1\"><input type=\"reset\" value=\"Reset\" name=\"B2\"></font></p>
</form> ";
}
}else{
echo mysql_error($conn);
}
and here is the update.php
$host = "localhost";
$user = "";
$password = "";
$db = "store";
$table = "manga";
$conn=mysql_connect($host,$user,$password) or die("Failed to connect");
mysql_select_db($db) or die("Falied to select database");
$id =$_POST['id'];
$code = $_POST['code'];
$name = $_POST['name'];
$author = $_POST['author'];
$price = $_POST['price'];
$lang = $_POST['language'];
$status = $_POST['status'];
$cato = $_POST['cato'];
$volumes = $_POST['nvolumes'];
$desc = $_POST['description'];
$lics = $_POST['licsd'];
$comp = $_POST['compl'];
$sql = ("UPDATE $table SET code='$code',manga_name = '$name', author = '$author',
pd_price ='$price',language ='$lang',status = '$status',cato ='$cato',n-volumes = '$volumes',
image-name = '$form_data_name',desc = '$desc',
Licensed = '$lics', complete = '$comp' WHERE id = '$id'");
// echo"(\"UPDATE $table SET code=\'$code\',manga_name = '$name', author = '$author',
//pd_price ='$price',language ='$lang',status = '$status',cato ='$cato',n-volumes = $volumes,
//image-name = '$form_data_name',desc = '$desc',
//Licensed = '$lics', complete = '$comp' WHERE id = '$id'\")";
// $sql = "UPDATE manga set VALUES('','$code','$name','$author','$price','$lang',
// '$status','$cato','$volumes','$form_data_name','$desc','$lics','$comp') where id = '$id'";
$result = mysql_query($sql);
if($result){
echo"the infromation was updated successfuly";
echo"<p><br>click <a href=manga_details.php?id=$myrow[id]>here</a> to view this manga details
<br>click <a href=manga_display.php?id=$myrow[id]>here</a> to view the manga list </p>";
}else{
echo mysql_error();
}