information won't pass

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

monkeynme
Forum Commoner
Posts: 28
Joined: Thu Aug 14, 2003 3:18 pm
Location: Colorado Springs, CO

information won't pass

Post by monkeynme »

I'm creating a master and detail page from my database. The master page lists the available JOBS and when a job is selected, the detail page lists all the other information for that job. Both pages are set up, but the JobID information is not being passed when a job link is selected. Only the details for the FIRST job in the list are displayed when ANY of the job links are selected. And the JobID variable is not shown at all. What am I missing? :?

The PHP setup for the master page is as follows:

Code: Select all

mysql_select_db($database_EagleMain, $EagleMain);
$query_Jobs = "SELECT jobID, jobTitle, jobPostdate, jobStatus FROM jobs ORDER BY jobPostdate ASC";
$Jobs = mysql_query($query_Jobs, $EagleMain) or die('<p>Error retrieving jobs from the database!<br> />'.
'Error: ' . mysql_error() . '</p>');
$row_Jobs = mysql_fetch_assoc($Jobs);
$totalRows_Jobs = mysql_num_rows($Jobs);
And the master table is as follows:

Code: Select all

&lt;td&gt;&lt;a href="jobdetail.php?id=$row_Jobs&#1111;'jobID']"&gt;&lt;?php echo $row_Jobs&#1111;'jobID']; ?&gt;&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;&lt;?php echo $row_Jobs&#1111;'jobTitle']; ?&gt;&lt;/td&gt; 
&lt;td&gt;&lt;?php echo $row_Jobs&#1111;'jobPostdate']; ?&gt;&lt;/td&gt;
&lt;td&gt;&lt;?php echo $row_Jobs&#1111;'jobStatus']; ?&gt;&lt;/td&gt;
The setup for the detail page is as follows:

Code: Select all

mysql_select_db($database_EagleMain, $EagleMain);
$query_Jobs = "SELECT * FROM jobs";
$Jobs = mysql_query($query_Jobs, $EagleMain) or die('<p>Error retrieving job details from the database!<br> />'.
'Error: ' . mysql_error() . '</p>');
$row_Jobs = mysql_fetch_assoc($Jobs);
$totalRows_Jobs = mysql_num_rows($Jobs);
$row_Jobs['jobID'] = $_GET['id'];
And the detail table is as follows:

Code: Select all

]&lt;tr&gt;&lt;td&gt;Job ID: &lt;?php echo $row_Jobs&#1111;'jobID']; ?&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Job Title: &lt;?php echo $row_Jobs&#1111;'jobTitle']; ?&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Status: &lt;?php echo $row_Jobs&#1111;'jobStatus']; ?&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Post Date:&lt;?php echo $row_Jobs&#1111;'jobPostdate']; ?&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Responsibilities: &lt;?php echo $row_Jobs&#1111;'jobRespons']; ?&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Qualifications:&lt;/strong&gt; &lt;?php echo $row_Jobs&#1111;'jobQualif']; ?&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Company/Product: &lt;?php echo $row_Jobs&#1111;'jobCompany']; ?&gt;&lt;/td&gt;&lt;/tr&gt;
murph
Forum Commoner
Posts: 29
Joined: Fri Oct 03, 2003 1:28 pm
Location: washington

Post by murph »

maybe because you didnt lose your php tags in the details table. you open php then you echo something but you never close the php tag.
monkeynme
Forum Commoner
Posts: 28
Joined: Thu Aug 14, 2003 3:18 pm
Location: Colorado Springs, CO

Post by monkeynme »

Oops, no actually the ?> symbols are there. I just accidentally deleted them in this post when I was stripping the code down for easy view. It should be:

<tr><td>Job ID: <?php echo $row_Jobs['jobID']; ?></td></tr>
<tr><td>Job Title: <?php echo $row_Jobs['jobTitle']; ?></td></tr>
<tr><td>Status: <?php echo $row_Jobs['jobStatus']; ?></td></tr>
<tr><td>Post Date:<?php echo $row_Jobs['jobPostdate']; ?></td></tr>
<tr><td>Responsibilities: <?php echo $row_Jobs['jobRespons']; ?></td></tr>
<tr><td>Qualifications:</strong> <?php echo $row_Jobs['jobQualif']; ?></td></tr>
<tr><td>Company/Product: <?php echo $row_Jobs['jobCompany']; ?></td></tr>
microthick
Forum Regular
Posts: 543
Joined: Wed Sep 24, 2003 2:15 pm
Location: Vancouver, BC

Post by microthick »

Code: Select all

mysql_select_db($database_EagleMain, $EagleMain);
$query_Jobs = "SELECT * FROM jobs";
$Jobs = mysql_query($query_Jobs, $EagleMain) or die('<p>Error retrieving job details from the database!<br> />'.
'Error: ' . mysql_error() . '</p>');
$row_Jobs = mysql_fetch_assoc($Jobs);
$totalRows_Jobs = mysql_num_rows($Jobs);
$row_Jobs&#1111;'jobID'] = $_GET&#1111;'id'];
This $row_Jobs['jobID'] = $_GET['id']; is new to me. Is this a fast way of just jumping to the array index you want?

Otherwise, it looks like an assignment and might cause your script to not work as planned.
monkeynme
Forum Commoner
Posts: 28
Joined: Thu Aug 14, 2003 3:18 pm
Location: Colorado Springs, CO

Post by monkeynme »

$row_Jobs['jobID'] = $_GET['id'];

This is my interpretation of another set of code where a list of jokes was created and then when you selected one, it took you to a page where the joke could be deleted form the database. This code was the closest i could find to a solution of GETing the info from my jobs list and sending it to the detail page. So if I misinterpreted it, I'm not surprised. But I don't know any other way to pass info other than the master page link:

<a href="jobdetail.php?id=$row_Jobs['jobID']"><?php echo $row_Jobs['jobID']; ?></a>

Please tell me you know a better way! :)
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

mysql_select_db($database_EagleMain, $EagleMain);
$query_Jobs = "SELECT * FROM jobs";
$Jobs = mysql_query($query_Jobs, $EagleMain) or die('<p>Error retrieving job details from the database!<br> />'.
'Error: ' . mysql_error() . '</p>');
$row_Jobs = mysql_fetch_assoc($Jobs);
$totalRows_Jobs = mysql_num_rows($Jobs);
$row_Jobs['jobID'] = $_GET['id'];
What's you're doing here is selecting all jobs from the database and doing one mysql_fetch_assoc, which will always be the first jobs details.
If you're passing the job id in the url as ?id=.. then your query should really be

Code: Select all

$query_Jobs = "SELECT * FROM jobs WHERE jobID=".$_GET['id'];
You should really select * .. but that's another story ;)
monkeynme
Forum Commoner
Posts: 28
Joined: Thu Aug 14, 2003 3:18 pm
Location: Colorado Springs, CO

Post by monkeynme »

I received an error with that change:

Code: Select all

Error retrieving job details from the database!
/>Error: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '&#1111;''jobID'']' at line 1
Line 1 of my code says: <?php require_once('Connections/EagleMain.php'); ?>

So I don't understand what happened.

I also tried:

Code: Select all

$query_Jobs = "SELECT * FROM jobs WHERE jobID='".$_GET&#1111;'id']."'";
Now there's no errors. The detail page shows up. But NONE of the database detail information is listed.
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

If jobid is an inter field then just
$query_Jobs = "SELECT * FROM jobs WHERE jobID=".$_GET['id'];
should work. i.e without the single quotes you put in.
monkeynme
Forum Commoner
Posts: 28
Joined: Thu Aug 14, 2003 3:18 pm
Location: Colorado Springs, CO

Post by monkeynme »

Nope that code:

Code: Select all

<?php
 mysql_select_db($database_EagleMain, $EagleMain);
$query_Jobs = "SELECT * FROM jobs WHERE jobID=".$_GET&#1111;'id']; 
$Jobs = mysql_query($query_Jobs, $EagleMain) or die('<p>Error retrieving job details from the database!<br> />'.
'Error: ' . mysql_error() . '</p>');
$row_Jobs = mysql_fetch_assoc($Jobs);
$totalRows_Jobs = mysql_num_rows($Jobs);
?>
still gives me the error:

Code: Select all

Error retrieving job details from the database! 
/>Error: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '&#1111;''jobID'']' at line 1
So if it should work, then maybe there's something wrong with the rest of the code in the script.
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

Yeah that's weird. It seems to think jobID has single quotes around it, so it's escaping them. I just don't see how it's possible for that query to produce that error. Might be worth triple checking you are in the right bit of code. Maybe putting some echo's around the query just to be sure..

Code: Select all

echo 'BEFORE QUERY<br />';
$query_Jobs = "SELECT * FROM jobs WHERE jobID=".$_GET['id'];
echo $query_Jobs.'<br />';
see what that outputs.
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

Also, just noticed your die() statement is bad

Code: Select all

die('<p>Error retrieving job details from the database!<br> />'. 
'Error: ' . mysql_error() . '</p>');
should be

Code: Select all

die('<p>Error retrieving job details from the database!<br />'. 
'Error: ' . mysql_error() . '</p>');
monkeynme
Forum Commoner
Posts: 28
Joined: Thu Aug 14, 2003 3:18 pm
Location: Colorado Springs, CO

Post by monkeynme »

It outputs this:

Code: Select all

BEFORE QUERY
SELECT * FROM jobs WHERE jobID=
Error retrieving job details from the database! 
/>Error: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '&#1111;''jobID'']' at line 1
By the way, the code for the dynamic text in the details table is still:

Code: Select all

<tr><td>Job ID: <?php echo $row_Jobs&#1111;'jobID']; ?></td></tr> 
<tr><td>Job Title: <?php echo $row_Jobs&#1111;'jobTitle']; ?></td></tr> 
<tr><td>Status: <?php echo $row_Jobs&#1111;'jobStatus']; ?></td></tr> 
<tr><td>Post Date:<?php echo $row_Jobs&#1111;'jobPostdate']; ?></td></tr> 
<tr><td>Responsibilities: <?php echo $row_Jobs&#1111;'jobRespons']; ?></td></tr> 
<tr><td>Qualifications:</strong> <?php echo $row_Jobs&#1111;'jobQualif']; ?></td></tr> 
<tr><td>Company/Product: <?php echo $row_Jobs&#1111;'jobCompany']; ?></td></tr>
Should that have changed when we added the GET condition?
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

What exactly does the full url of jobdetail.php look like when you goto it?
monkeynme
Forum Commoner
Posts: 28
Joined: Thu Aug 14, 2003 3:18 pm
Location: Colorado Springs, CO

Post by monkeynme »

markl999 wrote:Also, just noticed your die() statement is bad

Code: Select all

die('<p>Error retrieving job details from the database!<br> />'. 
'Error: ' . mysql_error() . '</p>');
should be

Code: Select all

die('<p>Error retrieving job details from the database!<br />'. 
'Error: ' . mysql_error() . '</p>');

Maybe it's just late, but I don't see a difference in the two.
monkeynme
Forum Commoner
Posts: 28
Joined: Thu Aug 14, 2003 3:18 pm
Location: Colorado Springs, CO

Post by monkeynme »

markl999 wrote:What exactly does the full url of jobdetail.php look like when you goto it?

Code: Select all

<td><a href="jobdetail.php?id=$row_Jobs&#1111;'jobID']"><?php echo $row_Jobs&#1111;'jobID']; </a></td>
Post Reply