I need help with getting my code correct. I keep getting syntax errors like the following.
You have an error in your SQL syntax near 'SET descrip = 'lalallalallal'WHERE catid = 4' at line 1
UPDATE categories SET name = 'Test'SET descrip = 'lalallalallal'WHERE catid = 4
What I am trying to do is after I have created a category in a table in my database, I would like to be able to edit and update the information that what submitted. I can get as far as being able to overwrite the new updates into the table in the database. The code im using to update the information from a form is as follows.
<?php
$sql = "SELECT * FROM categories WHERE catid = $catid";
@mysql_select_db($database_name_is_here) or die(mysql_error());
@$result = mysql_query($sql) or die(mysql_error().'<p>'.$sql.'</p>');
if (mysql_num_rows($result) < 1) {
echo 'Required information has been deleted.';
} else {
$sql = "UPDATE categories ";
$sql .= "SET name = '".addslashes(trim($name))."'";
$sql .= "SET descrip = '".addslashes(trim($descrip))."'";
$sql .= "WHERE catid = $catid";
@mysql_query($sql) or die(mysql_error().'<p>'.$sql.'</p>');
}
?>
Please help.
Thank you,
Matt Urban
aka -=URB=-
Help with PHP FORM TO UPDATE DATABASE
Moderator: General Moderators
- scarabatwork
- Forum Newbie
- Posts: 6
- Joined: Sat Mar 01, 2003 5:34 pm
- Location: Dallas, TX
- Contact: