Jump to content

mysql update


vystral

Recommended Posts

For some reason, my UPDATE query isn't working. I don't think I have the syntax wrong.

 

$restidquery="select restaurantid from restaurants where restaurantname='$restaurantname'";
  $restidresult=mysql_query($restidquery);
  $restidrow=@mysql_fetch_assoc($restidresult);
  $restid=$restidrow['restaurantid'];
  
  mysql_query("UPDATE users SET restaurantid='$restid' WHERE username='$username'") or die(mysql_error());

Link to comment
https://forums.phpfreaks.com/topic/52973-mysql-update/
Share on other sites

Use this for debugging:

 

<?php

$restidquery="select restaurantid from restaurants where restaurantname='$restaurantname'";
  $restidresult=mysql_query($restidquery) or die(mysql_error());
  $restidrow=mysql_fetch_assoc($restidresult);
  $restid=$restidrow['restaurantid'];
  
  $q = mysql_query("UPDATE users SET restaurantid='$restid' WHERE username='$username'") or die(mysql_error());

?>

 

Where are $restaurantname and $username defined?

Link to comment
https://forums.phpfreaks.com/topic/52973-mysql-update/#findComment-261664
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.