dflow Posted June 5, 2011 Share Posted June 5, 2011 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 '; Quote Link to comment https://forums.phpfreaks.com/topic/238486-query-not-getting-var/ Share on other sites More sharing options...
mikesta707 Posted June 5, 2011 Share Posted June 5, 2011 You need to use session_start in order to access the $_SESSION super global. session_start(): http://php.net/manual/en/function.session-start.php Quote Link to comment https://forums.phpfreaks.com/topic/238486-query-not-getting-var/#findComment-1225504 Share on other sites More sharing options...
dflow Posted June 5, 2011 Author Share Posted June 5, 2011 You need to use session_start in order to access the $_SESSION super global. session_start(): http://php.net/manual/en/function.session-start.php sorry these are lust the snippets of the query i have session_start and im echoing it correctly Quote Link to comment https://forums.phpfreaks.com/topic/238486-query-not-getting-var/#findComment-1225508 Share on other sites More sharing options...
Pikachu2000 Posted June 5, 2011 Share Posted June 5, 2011 Have you echoed the actual query string? Quote Link to comment https://forums.phpfreaks.com/topic/238486-query-not-getting-var/#findComment-1225509 Share on other sites More sharing options...
dflow Posted June 5, 2011 Author Share Posted June 5, 2011 here is what is echoed SELECT * FROM users LEFT JOIN bookings_admin_users ON bookings_admin_users.username = users.username WHERE users.userid=0a0a4721be44a75ae8465e8c576b863b LIMIT 0 , 30 Unknown column '0a0a4721be44a75ae8465e8c576b863b' in 'where clause' Quote Link to comment https://forums.phpfreaks.com/topic/238486-query-not-getting-var/#findComment-1225512 Share on other sites More sharing options...
mikesta707 Posted June 5, 2011 Share Posted June 5, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/238486-query-not-getting-var/#findComment-1225524 Share on other sites More sharing options...
dflow Posted June 5, 2011 Author Share Posted June 5, 2011 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 "; Quote Link to comment https://forums.phpfreaks.com/topic/238486-query-not-getting-var/#findComment-1225530 Share on other sites More sharing options...
mikesta707 Posted June 5, 2011 Share Posted June 5, 2011 Oh sorry, didn't noticed I misstyped there. yes thats correct Quote Link to comment https://forums.phpfreaks.com/topic/238486-query-not-getting-var/#findComment-1225534 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.