Lilith Posted December 9, 2010 Share Posted December 9, 2010 I ave tried to create a mining mod, but I get this error ... Funny thing is, the word inventory appears nowhere in my script. 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 '' at line 1 Query was SELECT * FROM inventory WHERE inv_userid=1 and inv_itemid= any hints? <?php include('globals.php'); //common stuff //mine gold if($ir['energy'] <= 4) { echo "You do not have enough energy. Come back later."; $h->endpage(); exit; } if($ir['jail'] || $ir['hospital']) { echo "You can't access this page while in the hospital or jail."; $h->endpage(); exit; } $cityname = $db->fetch_single($db->query("SELECT cityname FROM cities WHERE cityid = {$ir['location']}")); if(isset($_GET['search'])) //search { $type = mt_rand(1,11); $hard = mt_rand(1,3); // 1:3 chance of hard outcome, change this for each differnt ore $ore = Gold; $oreid = 115; $crystal = 116; $aqua = 117; $peri = 118; $Zirc = 119; $garnet = 120; $Emerald = 121; $Saphire = 122; $Ruby = 123; $Diam = 124; $BDimon = 125; switch($type) { case 1: if($hard == 1){ $amt = mt_rand(1,3); item_add($userid, $oreid, $amt); $out = "You collected Some Gold Ore."; }else{ $out = "There is nothing here."; } break; case 2: if($hard == 1){ $amt = mt_rand(1,3); item_add($userid, $oreid, $amt); $out = "You collected Some Gold Ore."; } if($hard == 2){ $amt = mt_rand(1,3); item_add($userid, $crystal, $amt); $out = "You collected {$amt} Quartz Crystals."; } if($hard == 3){ $out = "There is nothing here."; } break; case 3: if($hard == 1){ $amt = mt_rand(1,3); item_add($userid, $oreid, $amt); $out = "You collected Some Gold Ore."; } if($hard == 2){ $amt = mt_rand(1,3); item_add($userid, $aqua, $amt); $out = "You collected {$amt} Aquamarine."; } if($hard == 3){ $out = "There is nothing here."; } break; case 4: if($hard == 1){ $amt = mt_rand(1,3); item_add($userid, $oreid, $amt); $out = "You collected Some Gold Ore."; } if($hard == 2){ $amt = mt_rand(1,3); item_add($userid, $peri, $amt); $out = "You collected {$amt} Peridot."; } if($hard == 3){ $out = "There is nothing here."; } break; case 5: if($hard == 1){ $amt = mt_rand(1,3); item_add($userid, $oreid, $amt); $out = "You collected Some Gold Ore."; } if($hard == 2){ $amt = mt_rand(1,3); item_add($userid, $Zirc, $amt); $out = "You collected {$amt} Cubic Zirconium."; } if($hard == 3){ $out = "There is nothing here."; } break; case 6: if($hard == 1){ $amt = mt_rand(1,3); item_add($userid, $oreid, $amt); $out = "You collected Some Gold Ore."; } if($hard == 2){ $amt = mt_rand(1,3); item_add($userid, $garnet, $amt); $out = "You collected {$amt} Garnet."; } if($hard == 3){ $out = "There is nothing here."; } break; case 7: if($hard == 1){ $amt = mt_rand(1,3); item_add($userid, $oreid, $amt); $out = "You collected Some Gold Ore."; } if($hard == 2){ $amt = mt_rand(1,3); item_add($userid, $Emerald, $amt); $out = "You collected {$amt} Emerald."; } if($hard == 3){ $out = "There is nothing here."; }break; case 8: if($hard == 1){ $amt = mt_rand(1,3); item_add($userid, $oreid, $amt); $out = "You collected Some Gold Ore."; } if($hard == 2){ $amt = mt_rand(1,3); item_add($userid, $Saphire, $amt); $out = "You collected {$amt} Saphire."; } if($hard == 3){ $out = "There is nothing here."; } break; case 9: if($hard == 1){ $amt = mt_rand(1,3); item_add($userid, $oreid, $amt); $out = "You collected Some Gold Ore."; } if($hard == 2){ $amt = mt_rand(1,3); item_add($userid, $Ruby, $amt); $out = "You collected {$amt} Ruby."; } if($hard == 3){ $out = "There is nothing here."; } case 10: if($hard == 1){ $amt = mt_rand(1,3); item_add($userid, $oreid, $amt); $out = "You collected Some Gold Ore."; } if($hard == 2){ $amt = mt_rand(1,3); item_add($userid, $Diam, $amt); $out = "You collected {$amt} Diamond."; } if($hard == 3){ $out = "There is nothing here."; } case 11: if($hard == 1){ $amt = mt_rand(1,3); item_add($userid, $oreid, $amt); $out = "You collected Some Gold Ore."; } if($hard == 2){ $amt = mt_rand(1,3); item_add($userid, $BDimon, $amt); $out = "You collected {$amt} Blue Diamond."; } if($hard == 3){ $out = "There is nothing here."; } } $db->query("UPDATE users SET energy = energy- 3 WHERE userid = {$userid}"); //decrement energy ?> <div style="text-align:center"> <?= $out ?> <?= ($ir['energy']-3> 0) ? "<a href=\"?\">Search again?</a>" : "" ?> </div> <?php } else //index { ?> <h2 style="text-align:center;"><?= $cityname ?> Pond</center></h2> <div style="text-align:center;"> Welcome to the Mines, <?= $ir['username'] ?>. Mining Gold in Purgatory takes energy. Every time you mine, you energy loose 3 energy. Click on the image to Choose your ore! [img=/Oridian/upload/images/pond.png]</center> <map name='Map'> <area shape='rect' coords='2,2,66,66' href="?search"> <area shape='rect' coords='69,2,134,66' href="?search"> <area shape='rect' coords='138,2,202,66' href="?search"> <area shape='rect' coords='205,2,270,66' href="?search"> <area shape='rect' coords='274,2,338,66' href="?search"> <area shape='rect' coords='340,2,407,66' href="?search"> <area shape='rect' coords='2,70,66,133' href="?search"> <area shape='rect' coords='69,70,136,133' href="?search"> <area shape='rect' coords='137,70,202,133' href="?search"> <area shape='rect' coords='205,70,270,133' href="?search"> <area shape='rect' coords='274,70,338,133' href="?search"> <area shape='rect' coords='340,70,407,133' href="?search"> <area shape='rect' coords='2,138,405,202' href="?search"> <area shape='rect' coords='69,138,406,202' href="?search"> <area shape='rect' coords='137,138,338,202' href="?search"> <area shape='rect' coords='205,138,271,202' href="?search"> <area shape='rect' coords='274,138,338,202'href="?search"> <area shape='rect' coords='340,138,407,202' href="?search"> <area shape='rect' coords='2,206,66,270' href="?search"> <area shape='rect' coords='69,206,136,270' href="?search"> <area shape='rect' coords='137,206,202,270' href="?search"> <area shape='rect' coords='205,206,270,270' href="?search"> <area shape='rect' coords='274,206,338,270' href="?search"> <area shape='rect' coords='340,206,407,270' href="?search"> <area shape='rect' coords='2,273,66,337' href="?search"> <area shape='rect' coords='69,273,136,337' href="?search"> <area shape='rect' coords='137,273,202,337' href="?search"> <area shape='rect' coords='205,273,270,337' href="?search"> <area shape='rect' coords='274,273,338,337' href="?search"> <area shape='rect' coords='340,273,407,337' href="?search"> <area shape='rect' coords='2,341,66,405' href="?search"> <area shape='rect' coords='69,341,136,405' href="?search"> <area shape='rect' coords='137,341,202,405' href="?search"> <area shape='rect' coords='205,341,270,405' href="?search"> <area shape='rect' coords='274,341,338,405' href="?search"> <area shape='rect' coords='340,341,407,405' href="?search"> <area shape='rect' coords='2,410,66,473' href="?search"> <area shape='rect' coords='69,410,136,473' href="?search"> <area shape='rect' coords='137,410,202,473' href="?search"> <area shape='rect' coords='205,410,270,473' href="?search"> <area shape='rect' coords='274,410,338,473' href="?search"> <area shape='rect' coords='340,410,407,473' href="?search"> </map> </div> <?php } $h->endpage(); ?> Quote Link to comment Share on other sites More sharing options...
Kieran-R Posted December 9, 2010 Share Posted December 9, 2010 I cant see that query anywhere in the script you posted? Quote Link to comment Share on other sites More sharing options...
Dominion Posted December 9, 2010 Share Posted December 9, 2010 Query was SELECT * FROM inventory WHERE inv_userid=1 and inv_itemid= "inventory" table is used for the item_add() function so it is being used. is there a line number for your error or just that? Quote Link to comment Share on other sites More sharing options...
Lilith Posted December 9, 2010 Author Share Posted December 9, 2010 Thats the entire error! Funny thing is, I cant see how it is any different than how I did the add_item on the gem type items, and they are adding just fine. Im so confused! Quote Link to comment Share on other sites More sharing options...
Dominion Posted December 9, 2010 Share Posted December 9, 2010 Thats the entire error! Funny thing is, I cant see how it is any different than how I did the add_item on the gem type items, and they are adding just fine. Im so confused! if($hard == 2){ $amt = mt_rand(1,3); item_add($userid, $Saphire, $amt); $out = "You collected {$amt} Saphire."; } Where is $Saphire set? ^ lines 143-147 Quote Link to comment Share on other sites More sharing options...
Lilith Posted December 9, 2010 Author Share Posted December 9, 2010 try looking in lines 24 -35. Edit, ok, I see what you are saying, ill fix that, however, it has nothing to do with gold ore right? Quote Link to comment Share on other sites More sharing options...
Djkanna Posted December 9, 2010 Share Posted December 9, 2010 You defined $Saph not $Saphire. Quote Link to comment Share on other sites More sharing options...
Uridium Posted December 10, 2010 Share Posted December 10, 2010 didnt anyone notice this error :) change $hard = mt_rand(0,3); // 1:3 chance of hard outcome, change this for each differnt ore to $hard = mt_rand(1,3); // 1:3 chance of hard outcome, change this for each differnt ore As 0 will display a blank message Quote Link to comment Share on other sites More sharing options...
Lilith Posted December 10, 2010 Author Share Posted December 10, 2010 not me, lmao, or I would have fixed it! Note to self: dont use 0 in a mt_rand unless you account for it! Ok guys, I have updated the original script, and it is working as perfectly as I can tell. I went through over 100 mines with no issues. Me and my (edited) manners! Thank you all for your help! 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.