Seaholme Posted June 29, 2010 Share Posted June 29, 2010 It's hard to articulate this, but basically I have this bit of PHP // Get all the data from the dogs table $result = mysql_query("SELECT * FROM dogs WHERE owner='13'") or die(mysql_error()); And the general set-up is that I want the owner=13 bit to have it so that instead of 13, the database selects anything which has the same 'owner' number as the session ID. Or just basically some way to show only the dogs from the database where the person who's logged into the account is also their owner, rather than every player seeing every dog. I've tried the below, if it helps you to understand what I mean... // Get all the data from the dogs table $result = mysql_query("SELECT * FROM dogs WHERE owner='$_SESSION['id']") or die(mysql_error()); But I just get this error: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/content/91/6351791/html/camp.php on line 16 Can anybody help me work out how to tie in the user session (and therefore the user's ID) with picking certain things out of the database? Please let me know if anything needs explaining further! Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/206225-connecting-session-numbers-with-a-database/ Share on other sites More sharing options...
ToonMariner Posted June 29, 2010 Share Posted June 29, 2010 // Get all the data from the dogs table $result = mysql_query("SELECT * FROM dogs WHERE owner=".$_SESSION['id']) or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/206225-connecting-session-numbers-with-a-database/#findComment-1078939 Share on other sites More sharing options...
Seaholme Posted June 29, 2010 Author Share Posted June 29, 2010 Thanks -- that does solve the error I had before. Only now it says 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 I have a feeling I'm going about this the wrong way. Does anybody know I can tie a user's details and account session with the things (dogs in this case) belonging to that user, so they only see what belongs to them? Quote Link to comment https://forums.phpfreaks.com/topic/206225-connecting-session-numbers-with-a-database/#findComment-1078949 Share on other sites More sharing options...
Seaholme Posted June 30, 2010 Author Share Posted June 30, 2010 Wow, okay, I seem to have accidentally solved the second part to this myself! Yay xD Quote Link to comment https://forums.phpfreaks.com/topic/206225-connecting-session-numbers-with-a-database/#findComment-1078953 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.