Re: Modifying a record works but not in actual database?

From: Date: Sat, 09 Feb 2002 20:59:19 +0000
Subject: Re: Modifying a record works but not in actual database?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-84136@lists.php.net to get a copy of this message
try using // set up query $sql = "UPDATE thistable SET FNAME = \"$esc_fname\", LNAME = \"$esc_lname\", EMAIL = \"$esc_email\", WEB = \"$esc_web\" WHERE ID = \"$id\" "; variables aren't expanded inside ' so you need to use " Paul Roberts roberts_paul@bigfoot.com ++++++++++++++++++++++++ ----- Original Message ----- From: <lmlweb@mybc.com> To: <php-general@lists.php.net> Sent: Saturday, February 09, 2002 4:47 PM Subject: [PHP] Modifying a record works but not in actual database? > I'm trying to set up a "modify record" page, and after testing and > triple-checking > the syntax and form, and even running the query in the phpMyAdmin interface > to make sure the query is correct. > > This is just a snippet of what I've done: > > <?php > > // open connection > include ("connectdatabase.inc"); > > // format names to protects the O'Haras etc. > $esc_fname = addslashes($fname); > $esc_lname = addslashes($lname); > $esc_email = addslashes($email); > $esc_web = addslashes($web); > > // set up query > $sql = 'UPDATE thistable > SET FNAME = "$esc_fname", LNAME = "$esc_lname", EMAIL > = "$esc_email", WEB = "$esc_web" > WHERE ID = "$id"'; > > // perform query > $sql_result = mysql_query($sql); > if (!$sql_result) { > echo "Can't execute $sql " . mysql_error(); > exit; > } > > // close connection > mysql_close($connection); > ?> > > The problem? On the PHP front (my "mofidy record" page) says it's performed > without a problem. However, if I were to do a "view all records" - I > can see that none of the changes has actually been made to the database. > > Adding a record is not a problem; nor is deleting a record. > > Can someone point me into the right direction as to what I might be doing > wrong? > > Thanks! > > Laurie Landry > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > >

« previous php.general (#84136) next »