never was an update query I liked
Posted: Fri Aug 27, 2004 4:49 pm
I'm having a horrific day. Reminds me of the one I had a couple of
weeks ago. Then it was VBScript now it's php and I still can't quite
get the UPDATE query syntax correct.
What is wrong with this particular query?
mysql_query("UPDATE Table1 SET Username=$_POST["Username"] WHERE Ident='$str'",$db) or die(mysql_error());
________________________________________________
I keep getting the parse error (in Apache error_log):
unexpected '\"', expecting T_STRING or T_VARIABLE or T_NUM_STRING in /var/www/htdocs/updateaction.php on line 9
If I try Username='$_POST["Username"]' , same error
If I try Username=$_POST['Username'] I get: Undefined index
so Double quotes are definitely needed here.
The last entry also throws a web page mysql_error:
You have an error in your SQL syntax near '[Username] WHERE Ident='Easy Saber'' at line 1. **Note 'value' of variable displays
________________________________________________
However, if I try mysql_query('UPDATE Table1 SET Username=$_POST["Username"] WHERE Ident="$str"',$db) or die(mysql_error());
I don't get a parse error in the Apache error_log but I do get a mysql_error:
You have an error in your SQL syntax near '["Username"] WHERE Ident="$str"' at line 1
Will someone kindly rid me of my headache?
weeks ago. Then it was VBScript now it's php and I still can't quite
get the UPDATE query syntax correct.
What is wrong with this particular query?
mysql_query("UPDATE Table1 SET Username=$_POST["Username"] WHERE Ident='$str'",$db) or die(mysql_error());
________________________________________________
I keep getting the parse error (in Apache error_log):
unexpected '\"', expecting T_STRING or T_VARIABLE or T_NUM_STRING in /var/www/htdocs/updateaction.php on line 9
If I try Username='$_POST["Username"]' , same error
If I try Username=$_POST['Username'] I get: Undefined index
so Double quotes are definitely needed here.
The last entry also throws a web page mysql_error:
You have an error in your SQL syntax near '[Username] WHERE Ident='Easy Saber'' at line 1. **Note 'value' of variable displays
________________________________________________
However, if I try mysql_query('UPDATE Table1 SET Username=$_POST["Username"] WHERE Ident="$str"',$db) or die(mysql_error());
I don't get a parse error in the Apache error_log but I do get a mysql_error:
You have an error in your SQL syntax near '["Username"] WHERE Ident="$str"' at line 1
Will someone kindly rid me of my headache?