FaRmBoX Posted October 18, 2009 Share Posted October 18, 2009 I have a piece of code that is just not updating my SQL database. Its giving me a headache. I had success with it before, but not this time. Here is my form tag <form action="index.php?editsave=true" method="POST" enctype="multipart/form-data"> It also has a file upload, which is the only part that works... Here is the PHP code for receiving the form: ("save_edit" is the name of the submit button) if ($_POST['save_edit']) saveEdit($_POST['id'], $_POST['imagelink'], $_POST['name'], $_POST['price'], $_POST['desc'], $_POST['imagewidth'], $_POST['imageheight']); Which goes to a function called saveEdit: function saveEdit($id, $imagelink, $name, $price, $desc, $imagewidth, $imageheight) { $q = 'UPDATE main SET imagelink = "'.$imagelink.'", imagewidth = "'.$imagewidth.'", imageheight = "'.$imageheight.'", name = "'.$name.'", price = "'.$price.'", desc = "'.$desc.'" WHERE id = '.$id.''; // Run query $r = mysql_query($q); } My problem is that the above code does not update. The connection to the database works. The values from the form are saved to the correct variables. The value of q is in single quotes from my attempt to switch things around in case it worked when the double quotes didnt. Please help. Edit: I forgot to mention I get no errors with error_reporting(E_ALL); ini_set('display_errors', '1');. I find myself looking at a blank page. Link to comment https://forums.phpfreaks.com/topic/178080-solved-sql-syntax-update/ Share on other sites More sharing options...
Garethp Posted October 18, 2009 Share Posted October 18, 2009 Put the column names in ` and `, because it looks like you're using some reserved names. Also, if that doesn't work, put echo mysql_error(); at the bottom of your function Link to comment https://forums.phpfreaks.com/topic/178080-solved-sql-syntax-update/#findComment-938952 Share on other sites More sharing options...
FaRmBoX Posted October 18, 2009 Author Share Posted October 18, 2009 Thanks, putting the ``s around the column names fixed it. Link to comment https://forums.phpfreaks.com/topic/178080-solved-sql-syntax-update/#findComment-938953 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.