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 Problem should be easy

Status
Not open for further replies.

gokeeffe

Programmer
Jan 11, 2005
170
IE
can anyone see why the below code is not working. I've echo'd out county and user_id and they come out fine but
when I try to use the UPDATE statement it doesn't work, i keep getting failure. Please help.

Regards


$j = $_SESSION['county'];
echo "county = $j";
$a = $_SESSION['user_id'];
echo "user_id = $a";

$query_two = "UPDATE users SET id_county = '$j',
WHERE user_id = '$a'";
$result_two = mysql_query ($query_two);

if ($result_two)
{
echo'sucess';
}
else
{
echo'failure';
}
 
I get

UPDATE users SET id_county = '1', WHERE user_id = '434'failure
 
You should also try some more descriptive error messages such as:

Code:
$j = $_SESSION['county'];
echo "county = $j";
$a = $_SESSION['user_id'];
echo "user_id = $a";
        
$query_two = "UPDATE users SET  id_county = '$j',
             WHERE user_id = '$a'";
$result_two = mysql_query ($query_two);
if ($result_two){
  echo 'sucess';
}
else{
  echo 'Failure: Error on query:' . $query _two . '<br>' . mysql_error();
}

[cheers]
Cheers!
Laura
 
UPDATE users SET id_county = '1', WHERE user_id = '434'failure"

Eliminate the comma between the '1' and WHERE:

"UPDATE users SET id_county = '1' WHERE user_id = '434'failure"

[cheers]
Cheers!
Laura
 
Tks Laura,

It was the comma great spot, driving me mad for ages

Regards
Graham
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top