R: [PHP] SQL Query Not Kosher?

From: Date: Tue, 03 Feb 2004 13:44:36 +0000
Subject: R: [PHP] SQL Query Not Kosher?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-176675@lists.php.net to get a copy of this message
try removing curly braces as follows: $query = mysql_query("UPDATE stories SET status='approved' WHERE story_id={$id}"); | | | \/ $query = mysql_query("UPDATE stories SET status='approved' WHERE story_id=$id"); or $query = mysql_query("UPDATE stories SET status='approved' WHERE story_id=${id}"); this applies if story_id is of type int in mysql table definition, or you should enclose it among '' if is of type char, varchar or similar. cheers alessandro -----Messaggio originale----- Da: Mr. Austin [mailto:MrAustin@mn.rr.com] Inviato: martedì 3 febbraio 2004 5.35 A: php-general@lists.php.net Oggetto: [PHP] SQL Query Not Kosher? Hi all: I am trying to get this to work, but always get the same error: that the resource in mysql_affected_rows() is not valid. Anyone see why this would be? All variables have been tested for accuracy. $query = mysql_query("UPDATE stories SET status='approved' WHERE story_id={$id}"); if(mysql_affected_rows($query) == 1) { print("Your approval of \"$title\" was successful. If this user entered an email address, they have been sent a notice of its approval and publication on the site."); } else { print("The approval of \"$title\" was not successful. Please check with the site administrator for assistance."); } The above SQL statement works perfectly with phpMyAdmin (and, oddly enough, works with the above script, yet the Warning is produced and the 'not successful' message is displayed) Any thoughts are appreciated! Mr. Austin

« previous php.general (#176675) next »