Feky Posted June 19, 2009 Share Posted June 19, 2009 does anyone know what is wrong with ,when a item is found it does not to the user inventry //-- Finding items query $fia=(int) rand(10000,50000); $fib=(int) rand(10000,50000); if($fia == $fib) { $iq=mysql_query("SELECT * FROM items WHERE itmbuyable=1 ORDER BY rand() LIMIT 1",$c); $r=mysql_fetch_array($iq); $item=$r['itmid']; $userid=$ir['userid']; mysql_query("INSERT INTO inventory VALUES ('', $item, $userid, 1)",$c); event_add($userid,"You found a {$r['itmname']} While Walking Around the city.",$c); } } Quote Link to comment Share on other sites More sharing options...
EpicFuse Posted June 19, 2009 Share Posted June 19, 2009 Re: Finding items theres a } at the very bottem try to delete that maybe? :? Quote Link to comment Share on other sites More sharing options...
Feky Posted June 19, 2009 Author Share Posted June 19, 2009 Re: Finding items thats not the problem the problem is that the item dosent get sent to user inventry Quote Link to comment Share on other sites More sharing options...
eido Posted June 19, 2009 Share Posted June 19, 2009 Re: Finding items Change the mysql query to $db->query(then the rest See if that works +1 me if it works Quote Link to comment Share on other sites More sharing options...
eido Posted June 19, 2009 Share Posted June 19, 2009 Re: Finding items //-- Finding items query $fia=(int) rand(10000,50000); $fib=(int) rand(10000,50000); if($fia == $fib) { $iq=$db->query("SELECT * FROM items WHERE itmbuyable=1 ORDER BY rand() LIMIT 1",$c); $r=mysql_fetch_array($iq); $item=$r['itmid']; $userid=$ir['userid']; $db->query("INSERT INTO inventory VALUES ('', $item, $userid, 1)",$c); event_add($userid,"You found a {$r['itmname']} While Walking Around the city.",$c); } } Try that. Quote Link to comment Share on other sites More sharing options...
Feky Posted June 19, 2009 Author Share Posted June 19, 2009 Re: Finding items for some reason i get this error QUERY ERROR: Column count doesn't match value count at row 1 Query was INSERT INTO inventory VALUES ('', 59, 1, 1) Quote Link to comment Share on other sites More sharing options...
Kasabian Posted June 19, 2009 Share Posted June 19, 2009 Re: Finding items for some reason i get this error QUERY ERROR: Column count doesn't match value count at row 1 Query was INSERT INTO inventory VALUES ('', 59, 1, 1) Check the column's that are in inventory, you may have one for damage to the item or somthing of the following. if so just ad another value to that query e.g: $db->query("INSERT INTO inventory VALUES (' ', $item, $userid, 1,' ')",$c); You should also start to think about securing them. Quote Link to comment Share on other sites More sharing options...
CrazyT Posted June 20, 2009 Share Posted June 20, 2009 Re: Finding items Ok could i ask what was so hard about this?.. <?php //for colors of course :D $a = (int) rand(10000, 50000); $b = (int) rand(10000, 50000); if($a == $b) { $row = $db->fetch_row($db->query('SELECT `itmid`, `itmname` FROM `items` WHERE `itmbuyable` = 1 ORDER BY RAND() LIMIT 1')); item_add($ir['userid'], $row['itmid'], 1); event_add($ir['userid'], 'You found a '. $row['itmname'] .' While Walking Around the city.', $c); } There that should work. Quote Link to comment Share on other sites More sharing options...
virtualshogun Posted June 20, 2009 Share Posted June 20, 2009 Re: Finding items why not just modify explore.php right under <?php include "globals.php"; $tresder=(int) rand(100,999); add: $num=rand(1, 100); switch($num) { case 10: Print "you see someone getting beaten down better move on! "; break; case 40: $hospital=(int) rand(1,10); $loseruser = $ir['userid']; $hospreason = 'Beaten down in a back alley.'; $db->query("UPDATE users SET hospital=$hospital WHERE userid=$userid",$c); $db->query("UPDATE users SET hospreason='$hospreason' WHERE userid=$userid",$c); die ("!Random Event! turn down one street and get beat down! "); break; case 60: $gainer = rand(1,5); print "While looking around you find some cash and gained $gainer dollars!"; $db->query("update users set money=money+$gainer where userid=$userid",$c); break; } just a thought, 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.