What is wrong with this update query?

I get the echo “error” else statement, meaning the query didn’t run. What’s up? I’ve checked spelling for the fields in the database. I’ve made sure all variables are set correctly.:a:

 if($_GET['page'] == 'contact'){
 
   $id = $_GET['id'];
   $pe = escape_data($_GET['pubemail']);
   $co = escape_data($_GET['company']);
   $ut = escape_data($_GET['usertitle']);
   $a1 = escape_data($_GET['address1']);
   $a2 = escape_data($_GET['address2']);
   $ci = escape_data($_GET['city']);
   $st = escape_data($_GET['state']);
   $zi = escape_data($_GET['zipcode']);
   
   echo $id." ".$pe." ".$co." ".$ut." ".$a1." ".$a2." ".$ci." ".$st." ".$zi." ";
   
   $queryc = "UPDATE members SET pubemail='$pe', company='$co', usertitle='$ut', address1='$a1', address2='$a2', city='$ci', state='$st', zip='$zi' WHERE id=$id";
   $resultc = @mysql_query($queryc);
   if($resultc){echo "Contact Information Updated";}else{echo"error";}

}

dud check this out!!!

 
$queryc = "UPDATE members SET pubemail='$pe', 
company='$co', usertitle='$ut', address1='$a1', 
address2='$a2', city='$ci', state='$st', zip='$zi' 
WHERE id=$id"; 

the code [COLOR=red]WHERE id=$id[/COLOR]

[COLOR=black]make that [/COLOR][COLOR=blue]WHERE id=’$id’[/COLOR]

[COLOR=#0000ff]

 
$queryc = "UPDATE members SET pubemail='$pe', 
company='$co', usertitle='$ut', address1='$a1', 
address2='$a2', city='$ci', state='$st', zip='$zi' 
WHERE id='$id'"; 

[COLOR=black]rok on!!![/COLOR] :slight_smile:
[/COLOR]

Yeah I’ve done that and it still doesn’t work.

Actually if “id” is an integer (or numerical value), like I’m guessing it is, then it shouldn’t have the quotes around it.

I’ve had issues like this before where I’ve checked everything and still get an error. The solution’s been different most times – mainly because I messed something up. :stuck_out_tongue:

It’s hard to know what your DB set looks like. By just looking at the code, I need to ask. For the zip code (zip in the DB), is that an integer or are you allowing for non-numeric characters? If the zip is set up as an integer (or numerical value) then you wouldn’t need the quotes around the $zi.

If that doesn’t work, it would be helpful to see how you have your database set up.

Are you connecting to the database?
Maybe:

echo $id." “.$pe.” “.$co.” “.$ut.” “.$a1.” “.$a2.” “.$ci.” “.$st.” “.$zi.” ";

Should be
echo “”.$id." “.$pe.” “.$co.” “.$ut.” “.$a1.” “.$a2.” “.$ci.” “.$st.” “.$zi.” ";

else it beats the **** out of me.

That echo is just to check if the variable are set okay.
Here are my fields, all are varchar accept id=int, status=char(3), subscription=char(3)

id
firstname
lastname
email
username
password
access
pubemail
company
address1
address2
city
state
zip
service
zone
status
subscription
title

usertitle=‘$ut’ … I don’t see a “usertitle” in your database. There’s the problem: usertitle should be username

I setup a database and ran a test, orginally it failed to make the updates. I then changed usertitle=‘$ut’ to be username=‘$ut’ for your query and then it worked fine.

usertitle should be username

yeah!!!

Thanks Ankou that worked. Thanks for going through all the trouble to figure out my stupid mistake:P

No prob SlowRoasted, glad I could help. And hey, I’ve made that same mistake a few times in the past myself so I know how it goes!