Jump to content

SQL variable is undefined


blinks

Recommended Posts

I'd appreciate any assistance with the following code. When I echo the output, all the variables are correct, except that pokemon_pos is always 1, whereas it should be something like 49, which is the highest value in either tables trade_offers or pokemon_trainer for a given pokemon_trade_id.

 

$getdeclined="SELECT *
      FROM trade_offers
      WHERE pokemon_trade_id=$_GET[id]";
$declined=mysql_query($getdeclined);

while ($row = mysql_fetch_array($declined)){
$getdecusername="select max(pokemon_pos)
	from
	(
		select max(pokemon_pos) as pokemon_pos
		from pokemon_trainer
		WHERE pokemon_trainer = '$row[pokemon_trainer]'
		union all
		select max(pokemon_pos) 
		from trade_offers
		WHERE pokemon_trainer = '$row[pokemon_trainer]' AND pokemon_trade_id = $_GET[id]
	) as x";
$decusername=mysql_query($getdecusername);
while ($row2 = mysql_fetch_array($decusername)){
$newpos = $row2['pokemon_pos'];
$newpos +=1;
}
$update="UPDATE trade_offers
	 SET pokemon_pos = $newpos
	 WHERE pokemon_id = $row[pokemon_id]";
$result=mysql_query($update);
}

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.