Jump to content
MakeWebGames

Recommended Posts

Posted

*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

Posted
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);

 

Posted (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 by Magictallguy
Posted

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);

 

Posted

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...