Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update database failed--please help

Status
Not open for further replies.

ljCharlie

IS-IT--Management
Apr 21, 2003
397
US
I'm trying to update a MySQL database but the program kept failing. I believe the problem came from the WHERE clause where the comparison failed to make a match.

Below is my query:

$query = UPDATE members SET (FstName='$txtFstName', MdlName='$txtMdlName', LstName='$txtLstName') WHERE memberID ='$usrID';
$result = mysql_query($query);

The variable $usrID is a number string passing from an update .shtml page to the .php updated page. In the database, the memberID is defined as VARCHAR(50). Please tell me why the comparison failed to match to update.

Many thanks in advance!

ljCharlie
 
try the STRCMP(expr1,expr2) function which is intented for string comparison
 
Thanks for trying to help me. I tried the WHERE memberID ='" . $usrID . "'"; but it's not improving. I tried WHERE STRCMP('memberID','$usrID')" and still not working. I did try the echo $query; and the $usrID number was there in the query fine. The query showed the correct number. I even tried hard coding the $usrID into the memberID ='0027'" but the error is still the same. It just failed to make a match. However, if instead of an Update, I tried a Select query and it worked. The program matches in Select query but not when I do an Update query. I tried with and without the quote on both ends of the $usrID and nothing seems to be working.

ljCharlie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top