-
Posts
2,146 -
Joined
-
Last visited
-
Days Won
149
Content Type
Profiles
Forums
Events
Everything posted by Magictallguy
-
attack script not returning name, just numbers
Magictallguy replied to boionfire81's topic in Engine Support
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); //[...] -
attack script not returning name, just numbers
Magictallguy replied to boionfire81's topic in Engine Support
Also, MC Craps can feck off - ain't our fault they created a script so buggy that an entire community has to repair it -
attack script not returning name, just numbers
Magictallguy replied to boionfire81's topic in Engine Support
Look at the main select query for grabbing the user's data (should be within the top 30 lines by default) -
PAID REQUEST - TC cloned member dropdown function
Magictallguy replied to boionfire81's topic in Requests & In Production
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 -
mccode-v2 Updating Profile Image
Magictallguy replied to Samurai Legend's topic in Modification Support
Heh, that's my isImage function..- 15 replies
-
- mccode-v2
- mccode-lite
-
(and 3 more)
Tagged with:
-
If you don't have to use RegEx, don't. You can simply explode() it out using the comma separators..
-
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);
-
...My intentions were to poke a little fun, then backup your statement in agreement with you >.>
-
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
-
A darker theme would be much appreciated
-
Trunicating log enteries after 24 hours
Magictallguy replied to boionfire81's topic in Requests & In Production
This can also be done as just the query $db->query('DELETE FROM `table` WHERE `timestamp` <= (unix_timestamp() - 86400)'); -
PAID REQUEST - TC cloned member dropdown function
Magictallguy replied to boionfire81's topic in Requests & In Production
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 -
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
-
PAID REQUEST - TC cloned member dropdown function
Magictallguy replied to boionfire81's topic in Requests & In Production
Indeed. We can therefore assume that the stock jQuery packaged with MC Craps is no good. Try using the latest jQuery found here -
PAID REQUEST - TC cloned member dropdown function
Magictallguy replied to boionfire81's topic in Requests & In Production
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 ;) -
and http://makewebgames.io/forum/game-engines/mccode-development-support/engine-support/377702-sql-errors I'm gonna say no. Thanks though
-
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.'")');
-
PAID REQUEST - TC cloned member dropdown function
Magictallguy replied to boionfire81's topic in Requests & In Production
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 -
Change if($ir['timecard'] = 1) to if($ir['timecard'] == 1)
-
Whoops, sorry, that's my fault. Previous post updated
-
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
-
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.'")');
-
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);
-
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).
-
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);