bruckerrlb Posted August 4, 2007 Share Posted August 4, 2007 Hello! I have a simple script here, that takes the value of a query, and inserts it into an option field, below //I want to grab my session id here to put it in a variable (this session id is the member id, and I troubleshot it with a print statement, and it shows me the member id, which is the same as the client id) $memberid = $_SESSION['SESS_MEMBER_ID']; //This is my simple query to find make sure the client is only looking at his products $query = 'SELECT * FROM products WHERE clientid = $memberid'; //basic loop here if ($r = mysql_query ($query)) { while ($row = mysql_fetch_array ($r)) { print " //for some reason it's not printing the product name row, which is associated with the user who is logged in, i'm stumped <option>{$row['productname']}</option>"; } } else { //I don't get this error, I just get nothing returned in the select statement die ('could not do it because' .mysql_error(). "Damn"); } mysql_close(); So that is my problem in a nutshell, is my logic wrong? If anymore info is needed, please let me know, and thanks in advance for the help Quote Link to comment https://forums.phpfreaks.com/topic/63354-query-not-being-executed/ Share on other sites More sharing options...
BlueSkyIS Posted August 4, 2007 Share Posted August 4, 2007 Your single quotes are probably messing up your SQL. Try this: $query = "SELECT * FROM products WHERE clientid = '$memberid'"; -BSIS Quote Link to comment https://forums.phpfreaks.com/topic/63354-query-not-being-executed/#findComment-315732 Share on other sites More sharing options...
ballhogjoni Posted August 4, 2007 Share Posted August 4, 2007 $query = "SELECT * FROM products WHERE clientid = '$memberid'"; if that doesn't work try this $query = "SELECT * FROM products WHERE clientid = '{$memberid}'"; Quote Link to comment https://forums.phpfreaks.com/topic/63354-query-not-being-executed/#findComment-315734 Share on other sites More sharing options...
bruckerrlb Posted August 4, 2007 Author Share Posted August 4, 2007 you were right!!!!!!!!!!! Thank you so much, you've saved me God only knows how much hours, thanks! Quote Link to comment https://forums.phpfreaks.com/topic/63354-query-not-being-executed/#findComment-315735 Share on other sites More sharing options...
BlueSkyIS Posted August 4, 2007 Share Posted August 4, 2007 cheers! I was stuck on that problem a looooong time ago. -BSIS Quote Link to comment https://forums.phpfreaks.com/topic/63354-query-not-being-executed/#findComment-315736 Share on other sites More sharing options...
ballhogjoni Posted August 4, 2007 Share Posted August 4, 2007 better yet: $query = "SELECT * FROM products WHERE clientid = '{$memberid}'"; $r = mysql_query($query) or die(mysql_error()); while ($row = mysql_fetch_array($r) or die(mysql_error())) { //run script } Quote Link to comment https://forums.phpfreaks.com/topic/63354-query-not-being-executed/#findComment-315738 Share on other sites More sharing options...
bruckerrlb Posted August 5, 2007 Author Share Posted August 5, 2007 just curious, but why is that better? Quote Link to comment https://forums.phpfreaks.com/topic/63354-query-not-being-executed/#findComment-316046 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.