RE: [PHP-DB] Re: UPDATE Not Updating

From: Date: Fri, 03 Aug 2001 14:08:13 +0000
Subject: RE: [PHP-DB] Re: UPDATE Not Updating
Groups: php.db 
Request: Send a blank email to php-db+get-11031@lists.php.net to get a copy of this message
Are you using a form to submit data? If so, when you submit the data do you have the ContactID='' as a hidden form field so the variable is passed to perform the update? If you don't, then the ContactID variable will be NULL or 'empty' and the query will fail. Try doing something like this to see if the variable is actually being submitted to your form processor. (You could use isset instead of empty if you wish) $table_name = "contacts"; if(!$ContactID) { echo " No contact ID passed from form"; } else { update your table code here... } Why are you using double qoutes and escaping the qoutes? Can't you just use: UPDATE $table_name SET WHATEVER='$whatever' WHERE ContactID = '$ContactID' etc.... ========================== Karl Phillipson PHP SQL Programmer Saffron Hill Ventures 67 Clerkenwell Road London EC1R 5BL Saffron Hill: 0207 693 8300 -----Original Message----- From: Steve Fitzgerald [mailto:sf@mnetsys.com] Sent: 03 August 2001 14:40 To: php-db@lists.php.net Subject: [PHP-DB] Re: UPDATE Not Updating I echoed out the $update_contact_sql and I'm getting FirstName='Value', etc. WHERE ContactID='' There is no value in ContactID. I've changed the double quotes to single quotes and dropped the quotes all together with $ContactID. I ran the query in MySQL client and gave the ContactID a value which worked fine. I'm not sure why the query string is not passing the value. "Steve Fitzgerald" <sf@mnetsys.com> wrote in message news:20010801212400.29901.qmail@pb1.pair.com... > I belive this UPDATE should work, but it isn't. I get no errors. I have also > tried using FieldName= '$Fieldname', but that does not seem to work either. > > > > $table_name = "contacts"; > > > $update_contact_sql = "UPDATE $table_name > SET > FirstName =\"$FirstName\", > LastName = \"$LastName\", > Title = \"$Title\", > WorkPhone = \"$WorkPhone\", > HomePhone = \"$HomePhone\", > Mobile = \"$Mobile\", > EmailName = \"$EmailName\", > Birthday = \"$Birthday\" > WHERE ContactID = \"$ContactID\" > "; > > > $result = @mysql_query($update_contact_sql, $connection) or die ("Couldn't > execute query."); > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net For additional commands, e-mail: php-db-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.db (#11031) next »