Jump to content
MakeWebGames

Magictallguy

Administrators
  • Posts

    2,146
  • Joined

  • Last visited

  • Days Won

    149

Everything posted by Magictallguy

  1. Suggestion: Make MySQL do the majority of the work here.. $odata_sql = 'SELECT `userid`, `hp`, `infirmary`, `jail` `username`, `gang`, `location`, `maxhp`, `gender` `guard`, `agility`, `strength` FROM `users` NATURAL JOIN `userstats` WHERE `userid` = '.$_GET['ID']; $q = $db->query($odata_sql); //[...]
  2. Also, MC Craps can feck off - ain't our fault they created a script so buggy that an entire community has to repair it
  3. Look at the main select query for grabbing the user's data (should be within the top 30 lines by default)
  4. You appear to have a conflicting js imported in. Suggestion: Strip out *all* from the header. Add them back 1-by-1, starting with the JS required for the getList() (sent via PM). Once it stops working, you know which one is conflicting
  5. If you don't have to use RegEx, don't. You can simply explode() it out using the comma separators..
  6. He also hasn't defined $page as an argument in the function.. function page($page = 0) { if(!$page || !ctype_digit($page)) return false; if($ir['page'] != $page) { $db->query('UPDATE `users` SET `page` = '.$page.' WHERE `userid` = '.$ir['userid']); $db->query('INSERT INTO `logs` VALUES (NULL, '.$ir['userid'].', '.$page.', '.time().')'); } return true; } //Usage: page($whatever_variable_holds_the_page_number);
  7. ...My intentions were to poke a little fun, then backup your statement in agreement with you >.>
  8. For the record, it'd be page($page); And time() is a PHP funtion, not MySQL. You'll need to change it to either ".time()." or simply unix_timestamp() Oh, also [uSER=71663]IllegalPigeon[/uSER], lick my nipple! Backticks are useful! Then again, so are standardized naming conventions (not using things like `count`, `time`, `user`, `badly,named,table,with,commas`, etc. as table/column names) http://stackoverflow.com/a/11321508
  9. A darker theme would be much appreciated
  10. This can also be done as just the query $db->query('DELETE FROM `table` WHERE `timestamp` <= (unix_timestamp() - 86400)');
  11. I've tested this myself, it does work. I'd have to see your setup before I can diagnose further - feel free to shoot me a PM
  12. When coding late at night with all the lights off around you for 13 years almost non-stop, your eyes tend to hurt (or, at least, mine do!) So I've wrote up a dark CSS theme for MakeWebGames using the browser addon Stylish (Chrome/Firefox). It's easier on the eyes, I'll give it that much, but it's fugly as hell - still, it's a darker theme that makes my time on MWG easier for me. If anyone would like to chuck over updates/suggestions, please feel free! I can add them as options for customisation before installing the theme MakeWebGames Dark
  13. Indeed. We can therefore assume that the stock jQuery packaged with MC Craps is no good. Try using the latest jQuery found here
  14. Here's an example of it in a form designed to send an event to a user. <?php require_once __DIR__ . '/globals.php'; // If the form has been submitted if(array_key_exists('submit', $_POST)) { // Basic sanitation $_POST['user'] = array_key_exists('user', $_POST) && is_string($_POST['user']) ? $db->escape(trim($_POST['user'])) : null; $_POST['event'] = array_key_exists('event', $_POST) && is_string($_POST['event']) ? trim($_POST['event']) : null; // Basic validation if(empty($_POST['user'])) { echo 'You didn\'t select a valid user'; exit($h->endpage()); } if(empty($_POST['event'])) { echo 'You didn\'t enter a valid event text'; exit($h->endpage()); } // Get the user $select = $db->query('SELECT `userid` FROM `users` WHERE `username` = "'.$_POST['user'].'"'); // Does the user exist? if(!$db->num_rows($select)) { echo 'The user you selected doesn\'t exist'; exit($h->endpage()); } // Return the userid $user = $db->fetch_single($select); // Send the event event_add($user, $_POST['event']); echo 'The event has been sent<br />'; } // Display the form ?><form action="send_event.php" method="post"> <table class="table" width="100%"> <tr> <th width="25%">User</th> <td width="75%"><?php echo getList('user');?></td> </tr> <tr> <th>Event</th> <td><input type="text" name="event" /></td> </tr> <tr> <td colspan="2" class="center"><input type="submit" name="submit" value="Send Event" /></td> </tr> </table> </form><?php // Page footer $h->endpage();   If you were to stick that in a file called send_event.php, you'd be able to simply start typing a name to select a user. With the way the getList() function works, it'll return a username as the value so, we select the user based on the username entered. If the user doesn't exist, end the page. If the user does exist, return their respective userid and continue. Long story short; getList() returns a username as a value. Do with it as you wish ;)
  15. and http://makewebgames.io/forum/game-engines/mccode-development-support/engine-support/377702-sql-errors I'm gonna say no. Thanks though
  16. Do the same - restructure the query to have column name declarations $db->query('INSERT INTO `mail` (`mail_from`, `mail_to`, `mail_time`, `mail_subject`, `mail_text`) VALUES ('.$userid.', '.$to.', '.time().', "'.$subj.'", "'.$msg.'")');
  17. The MC Craps version of jQuery *should* suffice. As for the UI, https://code.jquery.com/ui/1.11.4/jquery-ui.min.js is what you're after
  18. Change if($ir['timecard'] = 1) to if($ir['timecard'] == 1)
  19. Whoops, sorry, that's my fault. Previous post updated
  20. Run this query on the database (CLI, phpMyAdmin, SQLBuddy, Adminer, etc.) ALTER TABLE `work` MODIFY `workId` INT(11) NOT NULL PRIMARY KEY AUTO_INCREMENT   My only guess now is that the `workId` hasn't been correctly set
  21. Right, you'll need to restructure your query to include column name declarations. This is based on stock MC Craps $db->query('INSERT INTO `items` (`itmtype`, `itmbuyprice`, `itmsellprice`, `itmbuyable`, `weapon`, `armor`, `effect1_on`, `effect2_on`, `effect3_on`, `effect1`, `effect2`, `effect3`, `itmname`, `itmdesc`) VALUES ('.$_POST['itmtype'].', '.$_POST['itmbuyprice'].', '.$_POST['itmsellprice'].', '.$itmbuy.', '.$weapon.', '.$armor.', '.$_POST['effect1on'].', '.$_POST['effect2on'].', '.$_POST['effect3on'].', "'.$efx1.'", "'.$efx2.'", "'.$efx3.'", "'.$itmname.'", "'.$itmdesc.'")');
  22. Your HTML was pointing GETDATA to job, not id or ID. $_GET['job'] = array_key_exists('job', $_GET) && ctype_digit($_GET['job']) ? $_GET['job'] : null; if(empty($_GET['job'])) { echo 'You didn\'t select a valid job rank'; exit($h->endpage()); } $sql = $db->query('SELECT * FROM `work_ranks` LEFT JOIN `work` ON `workId` = `rankJob` WHERE `workId` = `workFirst` AND `rankId` = '.$_GET['job']); if(!$db->num_rows($sql)) { echo 'That job rank doesn\'t exist'; exit($h->endpage()); } $r = $db->fetch_row($sql);  
  23. Chances are you're trying to insert a string into your INT field. Please provide the line of code generating this error, along with 5 lines above and 5 lines below (11 lines in total).
  24. Use the code I've provided. The fact that it returns null suggests that whatever you're specifying in the GETDATA isn't a valid job rank. Also, make sure you're sanitizing anything coming from the user. Assuming you haven't already, add this above the SELECT query. $_GET['ID'] = array_key_exists('ID', $_GET) && ctype_digit($_GET['ID']) ? $_GET['ID'] : null; if(empty($_GET['ID'])) { echo 'You didn\'t select a valid job rank'; exit($h->endpage()); }   So, the full sanitation and select should look like this: $_GET['job'] = array_key_exists('job', $_GET) && ctype_digit($_GET['job']) ? $_GET['job'] : null; if(empty($_GET['job'])) { echo 'You didn\'t select a valid job rank'; exit($h->endpage()); } $sql = $db->query('SELECT * FROM `work_ranks` LEFT JOIN `work` ON `workId` = `rankJob` WHERE `workId` = `workFirst` AND `rankId` = '.$_GET['job']); if(!$db->num_rows($sql)) { echo 'That job rank doesn\'t exist'; exit($h->endpage()); } $r = $db->fetch_row($sql);
×
×
  • Create New...