Hello:
Can someone help me out? I'm trying to pass a variable from one script to another. When I run the script, I receive the following message:
Notice: Undefined index: type2 in C:\Inetpub\fullfocus\Informed\view_program.php on line 20.
I highlighted the section in red which is producting the error message.
This is what's supposed to happen. In script one, I'm extracting the data in a lookup table. There is one entry per. I want to take the "type" field which contains the description and pass the description to the second script so it could be included in the title.
I included the code for both scripts.
This is the first script which creates the variable $type2 which I want to pass onto the next script.
require_once ('mysql_connect.php');
$query = "SELECT id, mortgage_type_id, type from mortgage_type";
$result = @mysql_query($query);
$num = mysql_num_rows($result);
if ($num > 0) {
echo '<table align="center" cellspacing="0" cellpadding="5">
<tr><td align="left"><b>ID</b></td>
<td align="left"><b>Mortgage Type</b><td>
</tr>';
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
$id = $row['id'];
$mtgid1 = $row['mortgage_type_id'];
$type2 = $row['type'];
echo '<tr>
<td align="left">' . $mtgid1 . '</td>
<td align="left"><a href="view_program.php?mortgage_type_id=' . $mtgid1 . '">' . $type2 . '</td>
</tr>';
}
echo '</table>';
mysql_free_result($result);
} else {
echo '<p class="error">There are currently no loan programs.</p>';
}
mysql_close();
?>
This is the second script where I would like the variable from the first to show up again.
<?php
$page_title = 'View the Current Loan Rates';
session_start();
$status = $_SESSION["status"];
switch ($status)
{
case "Not logged":
include "login.php";
break;
case "":
include "login.php";
break;
case "Logged":
include ('header4.html');
[COLOR="Red"]$type2a = $_SESSION["type2"];
echo '<span class="bold1">Current Loan Rates - $type2a</span><hr>';[/COLOR]
require_once ('mysql_connect.php');
if ( (isset($_GET['mortgage_type_id'])) && (is_numeric($_GET['mortgage_type_id'])) ) {
$id = $_GET['mortgage_type_id'];
}
else {
echo '<h1>Page Error</h1>
<p>This page has been accessed in error.</p><p><br /><br /></p>';
exit();
}
$query = "SELECT mortgage_type.id, mortgage_type.mortgage_type_id, mortgage_type.type, rates.id, rates.mortgage_type_id, rates.rate,
rates.price, rates.date, rates.time
FROM mortgage_type
LEFT JOIN rates
ON mortgage_type.id = rates.mortgage_type_id
WHERE mortgage_type.id = $id";
$result = @mysql_query ($query) or die (mysql_error());
echo '<table align="center" cellspacing="0" cellpadding="5">
<tr>
<td align="left"><b>ID</b></td>
<td align="left"><b>Mtg Type</b></td>
<td align="left"><b>Type</b></td>
<td align="left"><b>RateID</b></td>
<td align="left"><b>Mtg Type2</b></td>
<td align="left"><b>Rate</b></td>
<td align="left"><b>Price</b></td>
<td align="left"><b>Date</b></td>
<td align="left"><b>Time</b></td>
</tr>
';
while ($row = @mysql_fetch_array($result, MYSQL_ASSOC)) {
$id = $row['id'];
$mtgid1 = $row['mortgage_type_id'];
$type = $row['type'];
$rateid = $row['id'];
$mtgid2 = $row['mortgage_type_id'];
$rate = $row['rate'];
$price = $row['price'];
$date = $row['date'];
$time = $row['time'];
echo '
<td align="left">' . $id . '</td>
<td align="left">' . $mtgid1 . '</td>
<td align="left">' . $type . '</td>
<td align="left">' . $rateid . '</td>
<td align="left">' . $mtgid2 . '</td>
<td align="left">' . $rate . '</td>
<td align="left">' . $price . '</td>
<td align="left">' . $date . '</td>
<td align="left">' . $time . '</td>
</tr>
';
}
echo '</table>';
echo '<p><a href="welcome.php">Return to Load Administration Main Menu</a><br /><br />';
@mysql_free_result ($result); // Free up the resources.
mysql_close(); // Close the database connection.
?>
<?php
include('footer3.html');
?>
<?
}
?>
Thanks for all the help.