Jump to content
MakeWebGames

Jobs issue


MDF3

Recommended Posts

Hey guys,

When I get a job using my script, it says the following on the job page:

 

You currently work in the ! You receive $ each day at 5pm!

You also receive IQ, strength, and labour!

It also says nothing next to job rank. Does anyone know what the problem could be?

 

<?php
/*
Engine: MC V2.5 (Redux)
File: job.php
Author: mccodes.com
*/
if ( !defined($_CONFIG['define_code']) ) {
  echo 'This file cannot be accessed directly.';
  exit;
}
	$_GET['interview'] = ( isset($_GET['interview'])&&is_numeric($_GET['interview']) )?abs(intval($_GET['interview'])):'';
         if ( !$ir['job'] ) {
       if ( !$_GET['interview'] ) {
  echo "
How can you expect to get ahead in life without a job? Kids these days!<br /><br /> 
A list of available jobs is posted on the whiteboard below.<br /><br /><hr width='75%'><br />
  ";
$q = $db->query("SELECT `jID`,`jDESC`,`jNAME` FROM `jobs`");
    while ( $r = $db->fetch_row($q) ) {
  echo "
> {$r['jNAME']} - {$r['jDESC']} - <a href='".gen_url('job',true)."&interview={$r['jID']}'>Go to interview</a>
<br />
  ";
    }
       } else {
$q = $db->query("SELECT j.`jOWNER`,jr.`jrID`,`jrIQN`,`jrLABOURN`,`jrSTRN` FROM `jobs` j LEFT JOIN `jobranks` jr ON j.`jFIRST` = jr.`jrID` WHERE j.`jID` = {$_GET['interview']}");
$r = $db->fetch_row($q);
  echo "
{$r['jOWNER']}: I have looked over your resume, when are you available to start?
<br /><br />
{$ir['username']}: I can start immediately, if that is alright with you?<br /><br />";
      if ( $ir['strength'] >= $r['jrSTRN'] && $ir['labour'] >= $r['jrLABOURN'] && $ir['IQ'] >= $r['jrIQN'] ) {
$db->query("UPDATE `users` SET `job` = {$_GET['interview']},`jobrank` = {$r['jrID']} WHERE `userid` = $userid");
  echo "
{$r['jOWNER']}: Congratulations {$ir['username']}, you have gotten the job.
<br /><br />
{$ir['username']}: Thank you so much!
<br /><hr width='75%'>
> <a href='".gen_url('job',true)."'>Leave Interview</a>
    ";
      } else {
  echo "
{$r['jOWNER']}: Come back when you have 
  ";
    if ( $ir['strength'] < $r['jrSTRN'] ) {
	$s = $r['jrSTRN'] - $ir['strength'];
  echo " $s more strength, ";
    }
    if ( $ir['labour'] < $r['jrLABOURN'] ) {
	$s = $r['jrLABOURN'] - $ir['labour'];
  echo " $s more manual, ";
    }
    if ( $ir['IQ'] < $r['jrIQN'] ) {
	$s = $r['jrIQN'] - $ir['IQ'];
  echo " $s more intelligence, ";
    }
  echo "
and the job is yours.
<br /><hr width='75%'>
> <a href='".gen_url('job',true)."'>Leave Interview</a>
  ";
      }
       }
         } else {
switch($_GET['action']) {
	case 'quit': quit_job(); break;
	case 'promote': job_promote(); break;
	default: job_index(); break;
}
         }
function job_index() {
global $db, $ir,$c,$userid,$h;
  echo "
<h3>Job</h3>
You currently work in the {$ir['jNAME']}! You receive \${$ir['jrPAY']} each day at 5pm!
<br />
You also receive {$ir['jrIQG']} IQ, {$ir['jrSTRG']} strength, and {$ir['jrLABOURG']} labour!
<br />
<table width=50% cellspacing=1 class='table'>
	<tr>
<td>Strength: {$ir['strength']}</td>
<td>IQ: {$ir['IQ']}</td>
	</tr>
	<tr>
<td>Labour: {$ir['labour']}</td>
<td>Job Rank: {$ir['jrNAME']}</td>
	</tr>
</table>
<b>Job Ranks</b>
<br />
<table width=75% cellspacing=1 class='table'>
	<tr style='background:gray'>
<th>Title</th>
<th>Pay</th>
<th>Strength Reqd</th>
<th>IQ Reqd</th>
<th>Labour Reqd</th>
	</tr>
  ";
$q = $db->query("SELECT `jrNAME`,`jrPAY`,`jrSTRN`,`jrIQN`,`jrLABOURN` FROM `jobranks` WHERE `jrJOB` = {$ir['job']} ORDER BY `jrPAY` ASC");
    while ( $r = $db->fetch_row($q) ) {
  echo "
	<tr>
<td>{$r['jrNAME']}</td>
<td>\${$r['jrPAY']}</td>
<td>{$r['jrSTRN']}</td>
<td>{$r['jrIQN']}</td>
<td>{$r['jrLABOURN']}</td>
	</tr>
  ";
    }
  echo "
</table>
<br />
<a href='".gen_url('job',true)."&action=promote'>> Try To Get Promoted</a>
<br />
<a href='".gen_url('job',true)."&action=quit'>> Quit</a>
  ";
}

function job_promote() {
global $db,$ir,$c,$userid,$h;
$q = $db->query("SELECT `jrID`,`jrNAME` FROM `jobranks` WHERE `jrPAY` > '{$ir['jrPAY']}' AND `jrSTRN` <= '{$ir['strength']}' AND `jrLABOURN` <= '{$ir['labour']}' AND `jrIQN` <= '{$ir['IQ']}' AND `jrJOB` = '{$ir['job']}' ORDER BY `jrPAY` DESC LIMIT 1");
    if ( $db->num_rows($q) == 0 ) {
  echo "
Sorry, you cannot be promoted at this time.
<br />
> <a href='".gen_url('job',true)."'>Go Back</a>
  ";
    } else {
$r = $db->fetch_row($q);
$db->query("UPDATE `users` SET `jobrank` = {$r['jrID']} WHERE `userid` = $userid");
  echo "
Congrats, you have been promoted to {$r['jrNAME']}.
<br />
> <a href='".gen_url('job',true)."'>Go Back</a>
  ";
    }
}
function quit_job() {
global $db,$ir,$c,$userid,$h;
$db->query("UPDATE `users` SET `job` = 0,`jobrank` = 0 WHERE `userid` = $userid");
  echo "
You have quit your job!
<br />
> <a href='".gen_url('job',true)."'>Go Back</a>
  ";
}
	$h->endpage();
?>
Link to comment
Share on other sites

You currently work in the {$ir['jNAME']}! You receive \${$ir['jrPAY']} each day at 5pm!

You also receive {$ir['jrIQG']} IQ, {$ir['jrSTRG']} strength, and {$ir['jrLABOURG']} labour!

 

The $ir comes from the users table where userid = session user id. So this can mean either:

That info does not exist in that row.

OR

These columns do not exist in the users table.

Link to comment
Share on other sites

It could also be as simple as using a V2 modification on a V1 system.

I'd suggest you turn on error reporting for your script. If you don't know how, and you are with a hosting provider, ask them to assist you.

Please report back with the error, it should be either at a notice or warning level.

Link to comment
Share on other sites

You currently work in the {$ir['jNAME']}! You receive \${$ir['jrPAY']} each day at 5pm!

You also receive {$ir['jrIQG']} IQ, {$ir['jrSTRG']} strength, and {$ir['jrLABOURG']} labour!

 

The $ir comes from the users table where userid = session user id. So this can mean either:

That info does not exist in that row.

OR

These columns do not exist in the users table.

I do not know exactly what you mean, though this info may help.

There is a 'job' and a 'jobrank' column in the users table. Both of these have a value of '1' for my user, meaning that I have the first job and the first rank of that job?

'jNAME' appears to be in the 'jobs' table, and 'jrPAY', 'jrIQG', 'jrSTRG', and 'jrLABOURG' appear to be in the 'jobranks' table.

I am not sure if this information helps, though it seems that the page isn't getting information from these tables?

 

It could also be as simple as using a V2 modification on a V1 system.

I'd suggest you turn on error reporting for your script. If you don't know how, and you are with a hosting provider, ask them to assist you.

Please report back with the error, it should be either at a notice or warning level.

What do you mean? I have this problem out of the box, with an unmodified job.php file. I am using Redux (MCCODES 2.5).

I will have to look into turning error reporting on, though I usually see errors when something is wrong.

Link to comment
Share on other sites

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...