MySQL UPDATE issues [SOLVED]
Posted: Fri Apr 11, 2008 12:31 pm
~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:
Posting Code in the Forums to learn how to do it too.
Here's my code:
If the transaction is set at 'sub' it works perfectly, however when it is 'main' it gives me an error:
Thanks!
luke
~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:
Posting Code in the Forums to learn how to do it too.
Here's my code:
Code: Select all
if($_POST['type'] == 'main') {
$sql = "UPDATE main_pages " .
"SET name='" . $_POST['page_name'] .
"', desc='" . $_POST['page_desc'] .
"', content='" . $_POST['page_content'] .
"' WHERE id=" . $_POST['page_id'];
} else if ($_POST['type'] == 'sub') {
$sql = "UPDATE sub_pages " .
"SET sub_name='" . $_POST['page_name'] .
"', sub_desc='" . $_POST['page_desc'] .
"', sub_content='" . $_POST['page_content'] .
"' WHERE sub_id=" . $_POST['page_id'];
}
mysql_query($sql, $conn) or die('Could not update page; ' . mysql_error());I have no idea what my problem is... Any ideas?Could not update page; 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 'desc='H', content='t' WHERE id='1'' at line 1
Thanks!
luke
~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: