Jump to content
MakeWebGames

War_Hero

Members
  • Posts

    232
  • Joined

  • Last visited

Everything posted by War_Hero

  1. Re: Function Help Thank you for posting. I will try this when I can and post whether it worked or not. :)
  2. Re: MCCode v3 I think it'll cost around $200-$250. Hopefully it will be much better than V2. I wonder what new features would be included if it was released? :wink:
  3. Hi all. I'm still quite new to PHP so I get stuck on a few things. I'm creating a new mod called House Items. I'm not sure if it's been posted before, but what it does is allows the user to buy items to go with their house, for example an LCD TV, which increases their max will. Now, I've created the table in the database and created the staff options, in which, there are a few minor errors, but my main concern is with the actual purchasing of items. My table selects all the items from the house items table I made and displays them, but when I try and purchase the item, it doesn't come up with anything. It's just a blank screen. I'll post all of my code here, the staff_houseitems.php and houseitems.php, along with my SQL table. My staff_houseitems.php: <?php include "sglobals.php"; if($ir['user_level'] != 2) { die("403"); } //This contains House Items// switch($_GET['action']) { case 'addhitems': add_hitems(); break; case 'edithitems': edit_hitems(); break; case 'delhitems': del_hitems(); break; default: print "Error. This script requires an action."; break; } function add_hitems() { global $db,$ir,$c,$h,$userid; $name = $_POST['name']; $price = abs((int) $_POST['price']); $will = abs((int) $_POST['will']); if($name AND $price AND $will) { $q = $db->query(sprintf("SELECT * FROM `houseitems` WHERE `hitemsNAME` = '%d'", $r['hitemsNAME'])); if($db->num_rows($q)) { print "Sorry, you can not have two house items with the same name."; $h->endpage(); exit; } $db->query(sprintf("INSERT INTO `houseitems` VALUES(NOT NULL, '%d', '%d', '%d')", $name, $price, $will)); print "House item $name added to the game."; stafflog_add("Created House Item $name"); } else { print "<h3>Add House Item</h3> <hr /> <form action = 'staff_houseitems.php?action=addhitems' method = 'post' /> House Item Name: <input type = 'text' name = 'name' /> House Item Price: <input type = 'text' name = 'price' /> House Item Will: <input type = 'text' name = 'will' /> <input type = 'submit' value = 'Add House Item' /> </form>"; } } function edit_hitems() { global $db,$ir,$c,$h,$userid; switch($_POST['edit']) { case "2": $name = $_POST['name']; $price = abs((int) $_POST['price']); $will = abs((int) $_POST['will']); $q = $db->query(sprintf("SELECT * FROM `houseitems` WHERE `hitemsNAME` = '%d' AND `hitemsID` != '%d'", $name, $_POST['id'])); if($db->num_rows($q)) { print "You can not have two house items with the same name."; $h->endpage(); exit; } $name = $_POST['name']; $q = $db->query(sprintf("SELECT * FROM `houseitems` WHERE `hitemsID` = '%d'", $_POST['id'])); $old = $db->fetch_row($q); $db->query(sprintf("UPDATE `houseitems` SET `hitemsNAME` = '%d', `hitemsPRICE` = '%d', `hitemsWILL` = '%d' WHERE `hitemsID` = '%u'", $name, $price, $will, $_POST['id'])); print "House item $name edited successfully."; stafflog_add("Edited House Item $name"); break; case "1": $q = $db->query(sprintf("SELECT * FROM `houseitems` WHERE `hitemsID` = '%d'", $_POST['hitem'])); $old = $db->fetch_row($q); print "<h3 />Editing a House Item</h3> <hr /> <form action = 'staff_houseitems.php?action=edithitems' method = 'post' /> <input type = 'hidden' name = 'edit' value = '2' /> <input type = 'hidden' name = 'id' value = '{$_POST['hitem']}' /> House Item Name: <input type = 'text' name = 'name' value = '{$old['hitemsNAME']}' /> House Item Price: <input type = 'text' name = 'price' value = '{$old['hitemsPRICE']}' /> House Item Will: <input type = 'text' name = 'will' value = '{$old['hitemsWILL']}' /> <input type = 'submit' value = 'Edit House Item' /> </form>"; break; default: print "<h3 />Editing a House Item</h3> <hr /> <form action = 'staff_houseitems.php?action=edithitems' method = 'post' /> <input type = 'hidden' name = 'edit' value = '1' /> House Item: ".location_dropdown($c, "hitem")." <input type = 'submit' value = 'Edit House Item' /> </form>"; break; } } function del_hitems() { global $db,$ir,$c,$h,$userid; if($_POST['hitem']) { $q = $db->query(sprintf("SELECT * FROM `houseitems` WHERE `hitemsID` = '%d'", $_POST['hitem'])); $old = $db->fetch_row($q); if($old['hitemsID'] == 1) { die("This house item can not be deleted."); } $db->query(sprintf("DELETE FROM `houseitems` WHERE `hitemsID` = ('%u')", $old['hitemsID'])); print "House Item {$old['hitemsNAME']} deleted."; stafflog_add("Deleted House Item {$old['hitemsNAME']}"); } else { print "<h3 />Deleting a House Item</h3> <hr /> Deleting a House Item is permanent, so be sure you want to delete before you do. <form action = 'staff_houseitems.php?action=delhitems' method = 'post' /> House Item: ".location_dropdown($c, "hitem")." <input type = 'submit' value = 'Delete House Item' /> </form>"; } } $h->endpage(); ?> My error with this script is that whenever I create an item, it creates it without a name, just a number. I've looked at my code and can't see what is wrong with it. But that might be because I'm still a newbie. Plus, at the part House Item: ".location_dropdown($c, "hitem")." I'm not sure what to put in front of the _dropdown bit to display my house items. :? My houseitems.php: <?php include "globals.php"; if($ir['user_level'] != 2) { die("Under Construction"); } if($ir['jail'] or $ir['hospital']) { die("You can not buy items for your house when you're in jail or hospital."); } switch($_GET['action']) { case 'itembuy': item_buy(); break; case 'purchase': purchase(); break; default: index(); break; } function index() { global $db,$ir,$userid; print "<h1 />Furniture Shop</h1> Here, you can buy furniture for your home. Furniture ranges from carpets to LCD TVs. It's your choice what to buy, as long as you can afford it. <b />What would you like to do?[/b] > [url='houseitems.php?action=itembuy']Buy Furniture[/url] "; } function item_buy() { global $db,$ir,$userid; print "<h2 />Buying Furniture</h2> Welcome to the shop. How may we help you? Please keep in mind that you can only have <b />ONE[/b] of each item. "; $q = $db->query(sprintf("SELECT * FROM `houseitems` WHERE `hitemsID` = `hitemsID`")); print "<table width='75%' cellspacing='1' class='table' /> <tr /> <th />Furniture</th> <th />Price</th> <th />Max Will Increase</th> <th />Purchase?</th> </tr>"; while($r=$db->fetch_row($q)) { print " <tr /> <td />{$r['hitemsNAME']}</td> <td />{$r['hitemsPRICE']}</td> <td />{$r['hitemsWILL']}</td> <td />[url='houseitems.php?action=purchase&ID={$r[']Purchase[/url]</td> </tr>"; } print "</table>"; } function purchase() { global $db,$ir,$userid; $hprice = ($r['hitemsPRICE']); $hwill = ($r['hitemsWILL']); if($_GET['purchase']) { if($ir['money'] < $r['hitemsPRICE']) { die("You don't have enough money to buy this item."); } else { $db->query(sprintf("UPDATE `users` SET `money` = `money` - '%d', `maxwill` = `maxwill` + '%d' WHERE `userid` = ('%u')", $hprice, $hwill, $userid)); print "You have bought a(n) {$r['hitemsNAME']}. You feel happier already. Click [url='houseitems.php?action=itembuy']HERE[/url] to buy more items."; } } } $h->endpage(); ?> With this script, my main problem is the purchasing of items. As said above, the items are displayed, but when I click on purchase, a blank page appears. Again, I have tried numerous things but haven't been able to fix it. My SQL table: Name: houseitems Fields: 1) hitemsID 2) hitemsNAME 3) hitemsPRICE 4) hitemsWILL I appreciate any help given to me. Your help will also help me understand where I went wrong and help me improve my PHP skills. I'll update this post if I find any more bugs/errors. Thank you, War_Hero :)
  4. Re: News Paper Ads no sql I like this mod a lot. I have installed it on my brother's game and it works. I had to tweak a few things to do with adding and deleting ads, but overall a great mod! :)
  5. Re: Count Backwards :D 4914
  6. Re: Counting (nr game) 1930
  7. Re: Screening Mod and Research Facility Centre Mod [FREE][V2] You could try this: <?php include("globals.php"); if ($ir['jail'] or $ir['hospital']) { die("This page cannot be accessed when in jail or hospital. Click [url='index.php']HERE[/url] to return home."); } if ($ir['rfuse'] == 1) { die("You've been tested enough for today. Anymore tests, and you'll die. Come back when you're fit. Click [url='index.php']HERE[/url] to return home."); } $q = $db->query("SELECT * FROM `inventory` WHERE `inv_itemid` = 322 AND `inv_userid` = $userid"); if ($db->num_rows($q) > 0) { print "You have entered Area 1 of the research facility. You volunteer yourself to be used to test vacinations and medication for the virus. You were given $750 for testing the medication. Click [url='index.php']HERE[/url] to return home."; $db->query("UPDATE users SET hospital=hospital+35,hospreason='Tested new medication for money' WHERE userid=$userid", $c); $db->query("UPDATE users SET hp=0 WHERE userid=$userid", $c); $db->query("UPDATE users SET money=money+750 WHERE userid=$userid", $c); $db->query("UPDATE users SET rfuse=rfuse+1 WHERE userid=$userid", $c); $db->query("INSERT INTO inventory VALUES('',322,$userid,1)",$c); } else { die("You need a Research Facility Area 1 Key Card before you can enter Area 1. Click [url='index.php']HERE[/url] to go home."); } $h->endpage(); ?>   I replaced $db->query("UPDATE users SET inventory=inventory+1 WHERE itemid=322", $c);   with this: $db->query("INSERT INTO inventory VALUES('',322,$userid,1)",$c);   Unless otherwise, I don't think there's a field called `inventory` in the `users` table. :)
  8. Re: Screening Mod and Research Facility Centre Mod [FREE][V2] Fixed. :) And thanks for pointing that out = YarX =. :)
  9. Re: Screening Mod and Research Facility Centre Mod [FREE][V2] Thank you for the positive feedback. :) I will be attempting other mods shortly after I've developed my skills a bit more. War_Hero
  10. Re: Screening Mod and Research Facility Centre Mod [FREE][V2] Thank you for your reply Akash. I'll definetly take into account what you said. Cases and functions are one of my worst areas at the moment. I get stuck with them. :( As for making it easier to read, I should have spaced it out before I posted it. I admit, I forgot. :lol: But, because cases and functions are one my worst areas, I'll be trying my best to teach myself how they work. :)   And jds137, I'll re-post that script in a min. I found the error, I believe. There was an un-necessary ' in the script. It's my keyboard. It's not set to English, it's set to French or something because I'm in Belgium on holiday. :-P
  11. Re: Screening Mod and Research Facility Centre Mod [FREE][V2] Have you created a field in your users table called screen? If you have and the problem still occurs, please post you screen.php and I'll compare it with mine because mine works fine. :)
  12. Re: Query help please I've posted the entire mod under Free Game Modifications. :) Thanks to all of you. :)
  13. Re: Screening Mod and Research Facility Centre Mod [FREE][V2]   Thank you. :) I did work very hard on it. I'll be trying to improve my PHP skills a lot more. For example, working on security and cases/functions, which are my main two areas that cause me trouble. :-P
  14. Re: Screening Mod and Research Facility Centre Mod [FREE][V2] Thank you for the positive feedback. :) Yeah, security is one of main problems. So there may have to be some tightening up in places, which, I would be greatful to anyone who could show me how. :) It took me two days to code the Research Facility mod because I had some problems. And it took me about 1 hour to code the screening mod. :-P
  15. Hi all. This is my first mod, so it's not the best. I coded all of this from scratch. I'm not sure if it's been posted before either. This mod can be used if you decide to introduce a virus into your game. For example, I posted a news article in my newspaper about a virus spreading. So I created a mod that required the user to be screened before they accessed certain pages, and then re-screened after they travelled. Details Version: V2 Installation Time: Approx 10-20 mins So, the mod: Step 1 Create a file called screening.php and paste this code in it: <?php include "globals.php"; if($ir['jail'] or $ir['hospital']) { die("You cannot queue up to be screened when in hospital or jail."); } if($ir['screened'] == 1) { die("You must wait 5 minutes before you can be screened again."); } print "You queue up to get screened. After waiting for 45 minutes, it's your turn to be screened. Click [url='screen.php']HERE[/url] to get screened or [url='index.php']HERE[/url] if you're too scared."; $h->endpage(); ?>   Step 2 Run this SQL: ALTER TABLE `users` ADD `screened` INT(11) NOT NULL DEFAULT '0';   Step 3 Then add this cron into the cron_fivemins.php: $db->query("UPDATE users SET screened=0");   Step 4 Now create a file called screen.php and paste this code into it: <?php include "globals.php"; if($ir['jail'] or $ir['hospital']) { die("You cannot be screened when in hospital or jail."); } if($ir['screened'] == 1) { die("You must wait 5 minutes before you can be screened again."); } print "<h3 />Welcome to the Screening Lab</h3> "; if ($_GET['action'] != 'screen') { $screen=$ir['screen']; print "You are now being screened! "; } if ($ir['screen'] == 1) { print ("You only have to be screened once. You don't have to be screened again. "); } else { $outcome = rand(1,3); if ($outcome == 1) { print "The screening was successful. You don't have the virus/disease."; $db->query("UPDATE users SET screen=1 WHERE userid=$userid",$c); event_add($ir['userid'],"The screening was successful. You can now roam freely.",$c); } if ($outcome == 2) { $hosp = rand(200,350); print "The screening was successful, but the medication you were given has had a bad effect. You end up in the hospital for a while."; $db->query("UPDATE users SET screen=1 WHERE userid=$userid",$c); $db->query("UPDATE users SET hospital=hospital+$hosp,hospreason='Suffering from the screening medication' WHERE userid=$userid",$c); } if ($outcome == 3) { print "The screening was a <font color=red />FAILURE</font>"; $db->query("UPDATE users SET screen=0 WHERE userid=$userid",$c); $db->query("UPDATE users SET screened=1 WHERE userid=$userid",$c); } } $h->endpage() ?>   Step 5 Then run this SQL: ALTER TABLE `users` ADD `screen` INT(11) NOT NULL DEFAULT '0';   Step 6 Then add this cron into cron_day (or cron_hour.php if you want the users to be screened every hour): $db->query("UPDATE users SET screen=0");   Place this on every page that you want the user to have to be screened first before they can access it: if($ir['screen'] == 0) { die("You have to get screened before you can go here. To queue up, click [url='screening.php']HERE[/url]."); }   That's the screening part done. Now for the Research Facility. Step 1 Create an item called Research Facility Area 1 Key Card. Make it non-buyable with no effects. Step 2 Create a file called research.php and paste this code into it: <?php include "globals.php"; if($ir['jail'] or $ir['hospital']) { die("This page cannot be accessed when in jail or hospital."); } else { print "Welcome to the research facility centre. Click below to search the facility. <center />[url='researchcollect.php']SEARCH[/url]<center>"; } $h->endpage(); ?>   Step 3 Create a file called researchcollect.php and paste this code into it: <?php include "globals.php"; if($ir['jail'] or $ir['hospital']) { die("You cannot access this page when in the jail or hospital."); } if($ir['collect'] == 1) { die("It's illegal to enter the research centre without permission. Why risk it again? Click [url='index.php']here[/url] to go home."); } else { print "<h3 />Welcome to the Research Centre.</h3>"; if ($_GET['action'] != 'collect') { print "You begin searching the research center. After 20 minutes, "; } $rcollect = rand(1,6); if($rcollect == 1) { print "you find nothing and leave the research centre. Click [url='index.php']HERE[/url] to go home."; $db->query("UPDATE users SET collect=1 WHERE userid=$userid",$c); event_add($ir['userid'],"You didn't find anything while searching the research centre.",$c); } if($rcollect == 2) { $item=$db->query("SELECT * FROM items WHERE itmid=~~ITEM ID HERE~~",$c); print "you find a Research Facility Area 1 Key Card. You pocket the key card and head out of the research centre. Click [url='index.php']HERE[/url] to go home."; $db->query("UPDATE users SET collect=1 WHERE userid=$userid",$c); $db->query("INSERT INTO inventory VALUES('',~~ITEM ID HERE~~,$userid,1)",$c); event_add($ir['userid'],"You find a Research Facility Area 1 Key Card while searching the research centre.",$c); } if($rcollect == 3) { $ranmon = rand(200,500); print "you find nothing but a few pounds. You pocket the £$ranmon and head out of the centre. Click [url='index.php']HERE[/url] to go home."; $db->query("UPDATE users SET collect=1 WHERE userid=$userid",$c); $db->query("UPDATE users SET money=money+$ranmon WHERE userid=$userid",$c); event_add($ir['userid'],"You find $ranmon while searching the research centre.",$c); } if($rcollect == 4) { $jtime = rand(10,15); print "you find nothing. As you check the back corridor one last time, a security guard turns the corner and finds you rummaging through a bin. You're sent to jail for $jtime minutes. Click [url='index.php']HERE[/url] to go home."; $db->query("UPDATE users SET collect=1 WHERE userid=$userid",$c); $db->query("UPDATE users SET jail=jail+$jtime,jail_reason='Found rummaging through a bin at the research centre' WHERE userid=$userid",$c); event_add($ir['userid'],"You're sent to jail for $jtime minutes for rummaging through the bins at the research centre.",$c); } if($rcollect == 5) { print "you didn't find anything and head out of the research centre. Click [url='index.php']HERE[/url] to go home."; $db->query("UPDATE users SET collect=1 WHERE userid=$userid",$c); event_add($ir['userid'],"You didn't find anything while searching the research centre.",$c); } if($rcollect == 6) { $rancrys = rand(5,8); print "you find <font color=gold />$rancrys Golden Coins</font>, but that's it. So you head out of the research centre. Click [url='index.php']HERE[/url] to go home."; $db->query("UPDATE users SET collect=1 WHERE userid=$userid",$c); $db->query("UPDATE users SET crystals=crystals+$rancrys WHERE userid=$userid",$c); event_add($ir['userid'],"You gained $rancrys Golden Coins while searching the researching centre.",$c); } } $h->endpage(); ?>   NOTE: Replace ~~ITEM ID HERE~~ with the item ID of the Research Facility Area 1 Key Card Step 4 Run this SQL: ALTER TABLE `users` ADD `collect` INT(11) NOT NULL DEFAULT '0';   Step 5 Then add this cron into cron_day.php: $db->query("UPDATE users SET collect=0");   Step 6 Create a file called researchfacility.php and paste this code into it: <?php include "globals.php"; if($ir['jail'] or $ir['hospital']) { die("You cannot access this page when in hospital or jail."); } else { print "<h3 />Welcome to the Research Facility Centre.</h3>"; } if($_GET['action'] != 'use') { print "What would you like to do? <center>> [url='index.php']Go Home[/url] > [url='researcharea1.php']Enter Area 1[/url] </center>"; } $h->endpage(); ?>   Step 7 Create a file called researcharea1.php and paste this code into it: <?php include "globals.php"; if($ir['jail'] or $ir['hospital']) { die("This page cannot be accessed when in jail or hospital. Click [url='index.php']HERE[/url] to return home."); } if($ir['rfuse'] == 1) { die("You've been tested enough for today. Anymore tests, and you'll die. Come back when you're fit. Click [url='index.php']HERE[/url] to return home."); } $q = $db->query("SELECT * FROM `inventory` WHERE `inv_itemid` = ~~ITEM ID HERE~~ AND `inv_userid` = $userid"); if($db->num_rows($q) > 0) { print "You have entered Area 1 of the research facility. You volunteer yourself to be used to test vacinations and medication for the virus. You were given £5,000 for testing the medication. Click [url='index.php']HERE[/url] to return home."; $db->query("UPDATE users SET hospital=hospital+35,hospreason='Tested new medication for money' WHERE userid=$userid",$c); $db->query("UPDATE users SET hp=0 WHERE userid=$userid",$c); $db->query("UPDATE users SET money=money+75000 WHERE userid=$userid",$c); $db->query("UPDATE users SET rfuse=rfuse+1 WHERE userid=$userid",$c); item_remove($userid, ~~ITEM ID HERE~~, 1); } else { die("You need a Research Facility Area 1 Key Card before you can enter Area 1. Click [url='index.php']HERE[/url] to go home."); } $h->endpage(); ?>   NOTE: Replace ~~ITEM ID HERE~~ with the item ID of the Research Facility Area 1 Key Card Step 8 Then run this SQL: ALTER TABLE `users` ADD `rfuse` INT(11) NOT NULL DEFAULT '0';   Step 9 Then add this cron into cron_day.php: $db->query("UPDATE users SET rfuse=0");   And then you're done. I hope you enjoy. As I say, it's not the best because it's my first mod. :)   If you find any errors, please post them here. =] I've tested it on my brother's game and it works, so hopefully all will be well. :) I'd like to thank Floydian, Isomerizer and fbiss for helping me sort out some errors that occured during the making of this mod. Thank you. :)   EDIT: Re-posted the screen.php. There was an error in it. If anyone finds anymore errors, please post them here. :)
  16. Re: Query help please Yay! Thank you soo much fbiss. It works. I had to tweak a few things, but other than that, it works really well. And thank you to everyone else who helped me. :) Very much appreciated. Cheers, War_Hero :)
  17. Re: Query help please Thanks. It worked, because I'm no longer getting query errors. But now, there's something else wrong. It's not printing what I'd like it to. I have the required item, but it still says that I need that item to access the area. Here is my researcharea1.php with the updated queries: <?php include "globals.php"; if($ir['user_level'] != 2) { die("Under construction"); } if($ir['jail'] or $ir['hospital']) { die("This page cannot be accessed when in jail or hospital."); } if($ir['use'] == 1) { die("You've been tested enough for today. Anymore tests, and you'll die. Come back when you're fit."); } $db->query("SELECT * FROM inventory WHERE inv_itemid=95 AND inv_userid=$userid",$c); if($ir['inv_itemid'] == 95) { print "You have entered Area 1 of the research facility. You volunteer yourself to be used to test vacinations and medication for the virus. You were given £5,000 for testing the medication."; $db->query("UPDATE users SET money=money+5000,hospital=hospital+35,hospreason='Tested new medication for money' WHERE userid=$userid",$c); $db->query("UPDATE users SET use=1 WHERE userid=$userid",$c); $db->query("REMOVE * FROM inventory VALUES('',95,$userid,1)",$c); event_add($ir['userid'],"You tested some medication for the research centre and gained £5,000 but went into hospital for 35 minutes.",$c); } else { die("You need a Research Facility Area 1 Key Card before you can enter Area 1."); } $h->endpage(); ?>   What's wrong with it? :(
  18. Re: Query help please Hmm. I get a different query error now, but it's not as 'bad' as before: QUERY ERROR: Unknown column 'itmid' in 'where clause' Query was SELECT * FROM inventory WHERE itmid=95 AND userid=2 I'm thinking, do I have to encase the item id in ' '? :?
  19. Re: Query help please Oh, so would it be: $db-query("SELECT * FROM inventory WHERE itmid=95 AND userid=$userid",$c); I'll give that a go. :) And, would that be the same with removing the item from the inventory?   Thank you. :)
  20. Re: View Surrenders My brother had this problem on our game. But our problem was that the table still had uncompleted surrenders there. We had a full game reset and deleted everything but items and crimes, but forgot to truncate the surrenders table, so that was causing the problem. But now, it's all good. =]
  21. Re: Query help please The page above works well. But now, I get another query error with a different page, but related to the same topic. (I'm not much good with inventories. lol) I have a page called researchfacility.php, which gives the user two options, to go home or to enter an area called Area 1. If they choose to go to Area 1, they have to have a Research Facility Area 1 Key Card, which they could have obtained from searching the facility. I would like it so that if they don't have a card, they can't access Area 1. But if they do have a card, they can enter and they can get £5,000 by testing medication. But it doesn't work. :( Here is my researcharea1.php: <?php include "globals.php"; if($ir['user_level'] != 2) { die("Under construction"); } if($ir['jail'] or $ir['hospital']) { die("This page cannot be accessed when in jail or hospital."); } if($ir['use'] == 1) { die("You've been tested enough for today. Anymore tests, and you'll die. Come back when you're fit."); } $query = $db->query("SELECT * FROM inventory WHERE itmid=95,userid=$userid",$c); if($ir['$query']) { print "You have entered Area 1 of the research facility. You volunteer yourself to be used to test vacinations and medication for the virus. You were given £5,000 for testing the medication."; $db->query("UPDATE users SET money=money+5000,hospital=hospital+35,hospreason='Tested new medication for money' WHERE userid=$userid",$c); $db->query("UPDATE users SET use=1 WHERE userid=$userid",$c); } else { die("You need a Research Facility Area 1 Key Card before you can enter Area 1."); } $h->endpage(); ?>   And this is my query error: 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 'userid=2' at line 1 Query was SELECT * FROM inventory WHERE itmid=95,userid=2 And, I haven't tried it as of yet, but how would I make it so that when the user accesses Area 1, the card is removed from their inventory. Would it be something like: $db->query("REMOVE FROM inventory WHERE itmid=95,userid=$userid,1",$c); or something on those lines? Again, any help would be much appreciated. :) Thanks, War_Hero :)
  22. Re: Query help please Thank you very much. It worked. Now, I used ItemId 1 as a test. That's the Will Potion. So, when I want to change the item given, would I change it here: $item=$db->query("SELECT * FROM items WHERE itmid=95",$c); and here: $db->query("INSERT INTO inventory VALUES(",95,$userid,1)",$c); ? I'm not too sure about the second one....was the first 1 the item id?   And thanks again for helping me. :)   EDIT: Nevermind, I tried it and it worked. :) Thanks a lot, Floydian, for helping me. :D
  23. Hi all. I created this 'mod' to go with one of my news articles. My mod allows the users to search a research facility. There are a possible of 6 outcomes. One of the outcomes is that they find an item. (The item can then be used to enter a part of the research facility, but I haven't got to that part yet.) My problem is that I can't insert the item into the user's inventory when that particular outcome comes up. This is my researchcollect.php code: <?php include "globals.php"; if($ir['user_level'] != 2) { die("Under construction"); } if($ir['jail'] or $ir['hospital']) { die("You cannot access this page when in the jail or hospital."); } if($ir['collect'] == 1) { die("It's illegal to enter the research centre without permission. Why risk it again? Click [url='index.php']here[/url] to go home."); } else { print "<h3 />Welcome to the Research Centre.</h3>"; if ($_GET['action'] != 'collect') { print "You begin searching the research center. After 45 minutes, "; } $rcollect = rand(1,6); if($rcollect == 1) { print "you find nothing and leave the research centre."; $db->query("UPDATE users SET collect=1 WHERE userid=$userid",$c); event_add($ir['userid'],"You didn't find anything while searching the research centre.",$c); } if($rcollect == 2) { $item=$db->query("SELECT * FROM items WHERE itmid=1",$c); print "you find a Research Centre Area 1 Key Card. You pocket the key card and head out of the research centre."; $db->query("UPDATE users SET collect=1 WHERE userid=$userid",$c); $db->query("INSERT INTO inventory VALUES('',$item,$userid,1)",$c); event_add($ir['userid'],"You find a ['itmname'] while searching the research centre.",$c); } if($rcollect == 3) { $ranmon = rand(200,500); print "you find nothing but a few pounds. You pocket the £$ranmon and head out of the centre."; $db->query("UPDATE users SET collect=1 WHERE userid=$userid",$c); $db->query("UPDATE users SET money=money+$ranmon WHERE userid=$userid",$c); event_add($ir['userid'],"You find $ranmon while searching the research centre.",$c); } if($rcollect == 4) { $jtime = rand(10,15); print "you find nothing. As you check the back corridor one last time, a security guard turns the corner and finds you rummaging through a bin. You're sent to jail for $jtime minutes."; $db->query("UPDATE users SET collect=1 WHERE userid=$userid",$c); $db->query("UPDATE users SET jail=jail+$jtime,jail_reason='Found rummaging through a bin at the research centre' WHERE userid=$userid",$c); event_add($ir['userid'],"You're sent to jail for $jtime minutes for rummaging through the bins at the research centre.",$c); } if($rcollect == 5) { print "you didn't find anything and head out of the research centre."; $db->query("UPDATE users SET collect=1 WHERE userid=$userid",$c); event_add($ir['userid'],"You didn't find anything while searching the research centre.",$c); } if($rcollect == 6) { $rancrys = rand(5,8); print "you find <font color=gold />$rancrys Golden Coins</font>, but that's it. So you head out of the research centre."; $db->query("UPDATE users SET collect=1 WHERE userid=$userid",$c); $db->query("UPDATE users SET crystals=crystals+$rancrys WHERE userid=$userid",$c); event_add($ir['userid'],"You gained $rancrys Golden Coins while searching the researching centre.",$c); } } $h->endpage() ?>   This is the area that is causing me trouble: if($rcollect == 2) { $item=$db->query("SELECT * FROM items WHERE itmid=1",$c); print "you find a Research Centre Area 1 Key Card. You pocket the key card and head out of the research centre."; $db->query("UPDATE users SET collect=1 WHERE userid=$userid",$c); $db->query("INSERT INTO inventory VALUES('',$item,$userid,1)",$c); event_add($ir['userid'],"You find a ['itmname'] while searching the research centre.",$c); }   The query error I get is: 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 'id #12,2,1)' at line 1 Query was INSERT INTO inventory VALUES('',Resource id #12,2,1) I'm using V2 and I'm a n00b to PHP, so it's probably something very simple and easy, but any help of any sort would be much appreciated. :) Thanks, War_Hero :)
  24. Re: Login [Free] Fantastic work z-e-r-o. I have to admit, I'm jealous of your skills. I wish I had skills like that. lol Keep up the great work. :)
×
×
  • Create New...