phpisawesome Posted December 20, 2009 Share Posted December 20, 2009 do you guys know what's wrong with this syntax? $query_2 = "SELECT * FROM db WHERE id = " . $_SESSION[id]; Quote Link to comment Share on other sites More sharing options...
nafetski Posted December 20, 2009 Share Posted December 20, 2009 $query_2 = "SELECT * FROM db WHERE id = " . $_SESSION['id']; Forgot the single quotes around id Quote Link to comment Share on other sites More sharing options...
phpisawesome Posted December 20, 2009 Author Share Posted December 20, 2009 You positive? Did that and still syntax error. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted December 20, 2009 Share Posted December 20, 2009 Until you post the actual error, no one can help you with what is causing it. Quote Link to comment Share on other sites More sharing options...
phpisawesome Posted December 20, 2009 Author Share Posted December 20, 2009 The site just say's mysql error...i commented everything else out to break down the problem and it's that query... Quote Link to comment Share on other sites More sharing options...
trq Posted December 20, 2009 Share Posted December 20, 2009 The site just say's mysql error... mysql errors don't just simply state 'mysql error', you need to echo mysql_error to get more details about your error. Quote Link to comment Share on other sites More sharing options...
phpisawesome Posted December 20, 2009 Author Share Posted December 20, 2009 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 2 this is what i have currently... $query_2 = "SELECT * FROM db WHERE id = " . $_SESSION['id']; $results = mysql_query($query_2) or die (mysql_error()); Quote Link to comment Share on other sites More sharing options...
trq Posted December 20, 2009 Share Posted December 20, 2009 What does $_SESSION['id'] contain? Quote Link to comment Share on other sites More sharing options...
phpisawesome Posted December 20, 2009 Author Share Posted December 20, 2009 a number, basically corresponding to the person's id Quote Link to comment Share on other sites More sharing options...
trq Posted December 20, 2009 Share Posted December 20, 2009 echo $_SESSION['id'], it would appear it may contain some unwanted quotes. Quote Link to comment Share on other sites More sharing options...
phpisawesome Posted December 20, 2009 Author Share Posted December 20, 2009 I did, it's just a number...are you sure that query is the right format? Quote Link to comment Share on other sites More sharing options...
trq Posted December 20, 2009 Share Posted December 20, 2009 Yep, nothing wrong with the query. Can you echo $query_2 and show us the results? Quote Link to comment 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.