Jump to content

query not getting var


dflow

Recommended Posts

if the var is hard coded it is fine

im getting the session var as well

 

$userid is echoed but not affecting the query

echo $userid=$_SESSION['userid'];
mysql_select_db($database_sp, $sp);
$query_RsgetApID = 'SELECT * FROM users LEFT JOIN bookings_admin_users ON bookings_admin_users.username = users.username WHERE users.userid='.$userid.' LIMIT 0 , 30 ';

Link to comment
https://forums.phpfreaks.com/topic/238486-query-not-getting-var/
Share on other sites

oh well since you seem to be using a string, you need to surround your $userid variable with quotes. This is assuming ur userid column is of type varchar

 

$query_RsgetApID = "SELECT * FROM users LEFT JOIN bookings_admin_users ON bookings_admin_users.username = users.username WHERE users.userid='.$userid.' LIMIT 0 , 30 ";

 

unless thats some sort of hex typed column or something, but the default type for hex numbers in mysql is a string if I remember correctly

oh well since you seem to be using a string, you need to surround your $userid variable with quotes. This is assuming ur userid column is of type varchar

 

$query_RsgetApID = "SELECT * FROM users LEFT JOIN bookings_admin_users ON bookings_admin_users.username = users.username WHERE users.userid='.$userid.' LIMIT 0 , 30 ";

 

unless thats some sort of hex typed column or something, but the default type for hex numbers in mysql is a string if I remember correctly

 

ok found the solution, silly syntax i put the var inside '".$userid."' 

$query_RsgetApID = "SELECT * FROM users LEFT JOIN bookings_admin_users ON bookings_admin_users.username = users.username WHERE users.userid='".$userid."' LIMIT 0 , 30 ";

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.