Jump to content
MakeWebGames

[mccode2] problems with a single sql line and need help


MDK666

Recommended Posts

ok everyone im working on editing the attack.php file to include my inventory mod i had released some time ago, i have everything working up to this single line/s and i was wondering if someone can help out?

here is the error that i recieve:

 

QUERY ERROR: 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 'ORDER BY rand()' at line 1
Query was SELECT * FROM users WHERE itmid=(0, 0, 0, 0, 0, 0, 0 ORDER BY rand()

 

and here is the code:

 

{
$q3=$db->query("SELECT i.* FROM  items i WHERE i.itmid IN({$odata['equip_armor']}, {$odata['equip_helmet']}, {$odata['equip_boots']}, {$odata['equip_amulet']}, {$odata['equip_braclet']}, {$odata['equip_ring']}, {$odata['equip_special']} ORDER BY rand()"); 
if($db->num_rows($q3)) 
{
$mydamage-=$db->fetch_single($q3);
}

 

thats the part im getting confused at, i have a few people telling me the codeing is incorrect, and or i should use a array, but i dont know how to use a array along with writing one, i've tried multiple ways, i was thinking of useing this but not sure if it would work:

 

$q3=$db->query("SELECT * FROM users WHERE equipable={$equipable} ORDER BY rand()");
$equipable = array(
      helmet => array('equip_helmet'),
      armor => array('equip_armor'),
      braclet => array('equip_braclet'),
      boots => array('equip_boots'),
      amulet => array('equip_amulet'),
      ring => array('equip_ring'),
      special => array('equip_special')
);

 

if anyone has any suggestions of fixes for this ill greatly appreciate it.

Link to comment
Share on other sites

Re: [mccode2] problems with a single sql line and need help

Is it not common sense to close of your brackets and ()?'s

 

{
$q3=$db->query("SELECT i.* FROM  items i WHERE i.itmid IN({$odata['equip_armor']}, {$odata['equip_helmet']}, {$odata['equip_boots']}, {$odata['equip_amulet']}, {$odata['equip_braclet']}, {$odata['equip_ring']}, {$odata['equip_special']} ORDER BY rand()");
if($db->num_rows($q3))
{
$mydamage-=$db->fetch_single($q3);
}

 

should be

 

{
$q3=$db->query("SELECT i.* FROM  items i WHERE i.itmid IN({$odata['equip_armor']}, {$odata['equip_helmet']}, {$odata['equip_boots']}, {$odata['equip_amulet']}, {$odata['equip_braclet']}, {$odata['equip_ring']}, {$odata['equip_special']}) ORDER BY rand()");
if($db->num_rows($q3))
{
$mydamage-=$db->fetch_single($q3);
}
Link to comment
Share on other sites

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.   Paste as plain text instead

  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...