boionfire81 Posted June 30, 2016 Posted June 30, 2016 (edited) 1,2,3,4,5,6,7,8,9,10 Edited November 24, 2016 by boionfire81 Quote
Coly010 Posted June 30, 2016 Posted June 30, 2016 You are outputting it correctly as far as I can see. Run a var_dump($r); to see if you're getting the correct result from the db Quote
Magictallguy Posted June 30, 2016 Posted June 30, 2016 Just beat me to it [uSER=65530]Coly010[/uSER] :P [uSER=72582]boionfire81[/uSER], what is the content of $r? 1 Quote
Coly010 Posted July 1, 2016 Posted July 1, 2016 *facepalm* Not the code, we can read the code... When you run the code, what does the variable $r actually contain. Use var_dump($r); somewhere in your code after that snippet you posted and then go to the page and copy and past the massive array, if there is one Quote
Coly010 Posted July 1, 2016 Posted July 1, 2016 While you at look at this http://www.phpknowhow.com/basics/basic-debugging/ 1 Quote
Magictallguy Posted July 1, 2016 Posted July 1, 2016 content of $r $sql = sprintf("SELECT * FROM `work_ranks` LEFT JOIN `work` ON (`workId` = `rankJob`) WHERE `workId` = `workFirst` AND `rankId` = '%u'", $_GET['id']); $sql = $db->query($sql); $r = $db->fetch_row($sql); That be her right there^ As Coly said, not that code. However, I will ask anyway.. Why are you quoting an int? $sql = $db->query('SELECT * FROM `work_ranks` LEFT JOIN `work` ON `workId` = `rankJob` WHERE `workId` = `workFirst` AND `rankId` = '.$_GET['id']); if(!$db->num_rows($sql)) { echo 'That job rank doesn\'t exist'; exit($h->endpage()); } $r = $db->fetch_row($sql); Quote
Magictallguy Posted July 2, 2016 Posted July 2, 2016 (edited) 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); Edited July 2, 2016 by Magictallguy Quote
Magictallguy Posted July 2, 2016 Posted July 2, 2016 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); Quote
Magictallguy Posted July 3, 2016 Posted July 3, 2016 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 Quote
Magictallguy Posted July 3, 2016 Posted July 3, 2016 Change if($ir['timecard'] = 1) to if($ir['timecard'] == 1) Quote
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.