Jump to content

How can I get this piece of code too work?


xwishmasterx

Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.