xwishmasterx Posted April 10, 2011 Share Posted April 10, 2011 I have this little code that I cannot get to work $sql_buildings = ("SELECT castle, treasury, huts, [b]leader_id[/b] FROM teams WHERE team_id=[b]".$_GET['t']." [/b]"); $rsbuildings = mysql_query($sql_buildings); if($rsbuildings[".$_GET['t']."] == 'leader_id' ){ The problem is this part: if($rsbuildings[[b]".$_GET['t']."[/b]] == '[b]leader_id[/b]' ){ How can I write it to have these to values work? Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted April 10, 2011 Share Posted April 10, 2011 What problems are you having with it? What errors are you getting? Quote Link to comment Share on other sites More sharing options...
dcro2 Posted April 10, 2011 Share Posted April 10, 2011 Before you can access the row your mysql_query matched, you have to fetch one using one of the mysql_fetch functions. For example, mysql_fetch_array will return an array of the row with the array keys being the field names of your row. So if you called this: $row = mysql_fetch_array($rsbuildings); $row would then contain this: $row['castle'] => castle value $row['treasury'] => treasury value $row['huts'] => huts value $row['leader_id'] => leader_id value You'll have to explain what you're trying to do if you want us to actually help with the code. Quote Link to comment Share on other sites More sharing options...
xwishmasterx Posted April 10, 2011 Author Share Posted April 10, 2011 well the problem is this ".$_GET['t']." I get unexpected T-STRING error Same error on other page: buildings.php?t=$_GET['t']&r=$_GET['r']') Not sure how to write it as doing: echo "$_GET['t']"; works just fine Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted April 11, 2011 Share Posted April 11, 2011 Post the actual code you're having problems with, and the error messages you're getting. Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted April 11, 2011 Share Posted April 11, 2011 This <?php if($rsbuildings[".$_GET['t']."] == 'leader_id' ) ?> is not correct syntax, it should be <?php if($rsbuildings[$_GET['t']] == 'leader_id' ) ?> Ken 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.