Code: Select all
andCode: Select all
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
Im trying to do some php code to get variables to store info from a database that can then be used to put in a table...
this is the error im getting
[quote]Notice: Undefined variable: Harrier in c:\Inetpub\wwwroot\Assignment\Quote.php on line 199
Fatal error: Unsupported operand types in c:\Inetpub\wwwroot\Assignment\Quote.php on line 365
[/quote]
and the code:Code: Select all
<?php
session_start();
// reports session info
echo "Hello " . $_SESSION['username'];
echo "<br>[Session ID is " . session_id() . "]";
// closes down session activity for the rest of this script
session_write_close();
?>
<html>
<head>
<title>Your Quote</title>
<link href="css.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="wrapper">
<div id="banner"></div>
<div id="nav">
<ul>
<li><a href="register.htm">Register</a></li>
<li><a href="login.htm">Log in</a></li>
<li><a href="logout.php">Log Out</a></li>
<li><a href="order2.htm">Log Out</a></li>
<li><a href="Quote.php">Log Out</a></li>
</ul>
<?php
$ses = session_id();
// creates a new Common-Object-Model (COM) connection object
$adoCon = new COM("ADODB.Connection");
//=====================================//
// opens the connection using a standard Access connection string
try
{
$adoCon->Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:/Inetpub/wwwroot/Assignment/PRU.mdb");
}
catch(Exception $e)
{
die('Sorry - There was a problem with opening the database.<br />');
}
echo "hi jane database is open <br>";
$rsMain = $adoCon->Execute("SELECT * FROM T_order WHERE SesId = '$ses'");
// Outputs some fields from the order table
while (!$rsMain->EOF) // while not at "End Of File"...
{
$session = $rsMain->Fields("SesId");
$Harrier = $rsMain->Fields("Harrier");
$SixNut = $rsMain->Fields("6Nut");
$Mount342 = $rsMain->Fields("Mount342");
$Nut109 = $rsMain->Fields("109Nut");
$Seal312 = $rsMain->Fields("seal312");
$Tracking = $rsMain->Fields("Tracking");
$Wing = $rsMain->Fields("wing");
$Turbine = $rsMain->Fields("turbine");
$Injection = $rsMain->Fields("Injection");
$Seal = $rsMain->Fields("seal");
$Date = $rsMain->Fields("Date");
$rsMain->MoveNext();
}
// closes the recordset, frees up resources, kills all traces
echo "e";
//Get Pricearts info Harrier
$rsMain2 = $adoCon->Execute("SELECT CH_Price FROM T_Parts WHERE CH_Reference = 'AW156-78-02'");
// Outputs some fields from the table "tblUsers"
while (!$rsMain2->EOF) // while not at "End Of File"...
{
$HarPrice = $rsMain2->Fields("CH_Price");
$rsMain2->MoveNext();
}
// closes the recordset, frees up resources, kills all traces
echo "smelly";
//Get Pricearts info type 6 nut
$rsMain3 = $adoCon->Execute("SELECT CH_Price FROM T_Parts WHERE CH_Reference = 'AG12-34-9'");
// Outputs some fields
while (!$rsMain3->EOF) // while not at "End Of File"...
{
$Nut6Price = $rsMain3->Fields("CH_Price");
$rsMain3->MoveNext();
}
// closes the recordset, frees up resources, kills all traces
echo "wow";
//Get Pricearts info Mount342
$rsMain4 = $adoCon->Execute("SELECT CH_Price FROM T_Parts WHERE CH_Reference = 'RE3-426-0'");
// Outputs some fields
while (!$rsMain4->EOF) // while not at "End Of File"...
{
$MountPrice = $rsMain4->Fields("CH_Price");
$rsMain4->MoveNext();
}
// closes the recordset, frees up resources, kills all traces<table width="200" border="1">
echo "yoy";
//Get Pricearts info Type 109 nut
$rsMain5 = $adoCon->Execute("SELECT CH_Price FROM T_Parts WHERE CH_Reference = 'AB678-90'");
// Outputs some fields
while (!$rsMain5->EOF) // while not at "End Of File"...
{
$Nut109Price = $rsMain5->Fields("CH_Price");
$rsMain5->MoveNext();
}
// closes the recordset, frees up resources, kills all traces
echo "elelelel";
//Get Pricearts info Seal 312
$rsMain6 = $adoCon->Execute("SELECT CH_Price FROM T_Parts WHERE CH_Reference = 'CS546-39-09'");
// Outputs some fields
while (!$rsMain6->EOF) // while not at "End Of File"...
{
$Seal312Price = $rsMain6->Fields("CH_Price");
$rsMain6->MoveNext();
}
// closes the recordset, frees up resources, kills all traces
echo "yo dude";
//Get Pricearts info Tracking checker
$rsMain7 = $adoCon->Execute("SELECT CH_Price FROM T_Parts WHERE CH_Reference = 'TR54-32-190-1'");
// Outputs some fields
while (!$rsMain7->EOF) // while not at "End Of File"...
{
$TrackPrice = $rsMain7->Fields("CH_Price");
$rsMain7->MoveNext();
}
// closes the recordset, frees up resources, kills all traces<table width="200" border="1">
echo "mum and dad";
//Get Pricearts info Wing Tip Light
$rsMain8 = $adoCon->Execute("SELECT CH_Price FROM T_Parts WHERE CH_Reference = 'YY3-636-48-9'");
// Outputs some fields
while (!$rsMain8->EOF) // while not at "End Of File"...
{
$WingPrice = $rsMain8->Fields("CH_Price");
$rsMain8->MoveNext();
}
// closes the recordset, frees up resources, kills all traces<table width="200" border="1">
echo "oops this code doesnt work";
//Get Pricearts info Turbine Blade
$rsMain9 = $adoCon->Execute("SELECT CH_Price FROM T_Parts WHERE CH_Reference = 'YY65-47-8'");
// Outputs some fields
while (!$rsMain9->EOF) // while not at "End Of File"...
{
$TurbPrice = $rsMain9->Fields("CH_Price");
$rsMain9->MoveNext();
}
// closes the recordset, frees up resources, kills all traces
echo "ben smells";
//Get Pricearts info Injection Unit
$rsMain10 = $adoCon->Execute("SELECT CH_Price FROM T_Parts WHERE CH_Reference = 'IP09873-65-19'");
// Outputs some fields
while (!$rsMain10->EOF) // while not at "End Of File"...
{
$InjPrice = $rsMain10->Fields("CH_Price");
$rsMain10->MoveNext();
}
// closes the recordset, frees up resources, kills all traces
echo "tissue";
//Get Pricearts info Seal
$rsMain11 = $adoCon->Execute("SELECT CH_Price FROM T_Parts WHERE CH_Reference = 'YT3242-98-0'");
// Outputs some fields
while (!$rsMain11->EOF) // while not at "End Of File"...
{
$SealPrice = $rsMain11->Fields("CH_Price");
$rsMain11->MoveNext();
}
// closes the recordset, frees up resources, kills all traces
//........///...............///
//Calculate Subtotals of each item
$QHarrier =$Harrier * $HarPrice;
$Q6Nut =$SixNut * $Nut6Price;
$QMount =$Mount342 * $MountPrice;
$QNut109 =$Nut109 * $Nut109Price;
$QSeal312 =$Seal312 * $Seal312Price;
$QTrack =$Tracking * $TrackPrice;
$QWing =$Wing * $WingPrice;
$QTurb =$Turbine * $TurbPrice;
$QInj =$Injection * $InjPrice;
$QSeal =$Seal * $SealPrice;
echo "jane";
//------------//-------------//
//Calculate Subtotal
$Subtotal = ($QHarrier + $Q6Nut + $QMount + $QNut109 + $QSeal312 + $QTrack + $QWing + $QTurb + $QInj + $QSeal);
//Calculate VAT
$Vat = (Subtotal * 0.175);
//Calculate Total
$Total = $Subtotal + $Vat;
//-------------------------------------//
//--Print Table--//
print "<table>";
print "<tr>";
print "<th scope='col'>Part</th>";
print "<th scope='col'>Unit Price </th>";
print "<th scope='col'>Quantity</th>";
print "<th scope='col'>Subtotal</th>";
print "</tr>";
print " <tr>";
print "<th scope='row'>Harrier Wing Assembly</th>";
print "<td>$HarPrice</td>";
print "<td>$Harrier</td>";
print "<td>$QHarrier</td>";
print "</tr>";
print "<tr>";
print "<th scope='row'>Type 6 Nut</th>";
print "<td>$Nut6Price</td>";
print "<td>$6Nut</td>";
print "<td>$Q6Nut </td>";
print "</tr>";
print "<tr>";
print "<th scope='row'>Mount 342</th>";
print "<td>$MountPrice</td>";
print "<td>$Mount342</td>";
print "<td>$QMount </td>";
print "</tr>";
print "<tr>";
print "<th scope='row'>Type 109 nut</th>";
print "<td>$Nut109Price </td>";
print "<td>$Nut109</td>";
print "<td>$QNut109</td>";
print "</tr>";
print "<tr>";
print "<th scope='row'>Seal 312</th>";
print "<td>$Seal312Price</td>";
print "<td>$Seal312</td>";
print "<td>$QSeal312</td>";
print "</tr>";
print "<tr>";
print "<th scope='row'>Tracking Checker</th>";
print "<td>$TrackPrice</td>";
print "<td>$Tracking</td>";
print "<td>$QTrack</td>";
print "</tr>";
print "<tr>";
print "<th scope='row'>Wing Tip Light 967</th>";
print "<td>$WingPrice</td>";
print "<td>$Wing</td>";
print "<td>$QWing</td>";
print "</tr>";
print "<tr>";
print "<th scope='row'>Turbine Blade 34421</th>";
print "<td>$TurbPrice</td>";
print "<td>$Turbine</td>";
print "<td>$QTurb</td>";
print "</tr>";
print "<tr>";
print "<th scope='row'>Type AB323 Injection Unit</th>";
print "<td>$InjPrice</td>";
print "<td>$Injection</td>";
print "<td>$QInj</td>";
print "</tr>";
print "<tr>";
print "<th scope='row'>Seal</th>";
print "<td>$SealPrice</td>";
print "<td>$Seal</td>";
print "<td>$QSeal</td>";
print "</tr>";
print "</table>";
//--- prints totals table
print "<table>";
print "<tr>";
print "<th scope='row'>SubTotal</th>";
print "<td>$Subtotal</td>";
print "</tr>";
print "<tr>";
print "<th scope='row'>VAT</th>";
print "<td>$Vat</td>";
print "</tr>";
print "<tr>";
print "<th scope='row'>Total</th>";
print "<td>$Total</td>";
print "</tr>";
print "</table>";
$rsMain->Close();
$rsMain->Release();
$rsMain = null;
$rsMain2->Close();
$rsMain2->Release();
$rsMain2 = null;
$rsMain3->Close();
$rsMain3->Release();
$rsMain3 = null;
$rsMain4->Close();
$rsMain4->Release();
$rsMain4 = null;
$rsMain5->Close();
$rsMain5->Release();
$rsMain5 = null;
$rsMain6->Close();
$rsMain6->Release();
$rsMain6= null;
$rsMain7->Close();
$rsMain7->Release();
$rsMain7= null;
$rsMain8->Close();
$rsMain8->Release();
$rsMain8= null;
$rsMain9->Close();
$rsMain9->Release();
$rsMain9= null;
$rsMain10->Close();
$rsMain10->Release();
$rsMain10= null;
$rsMain11->Close();
$rsMain11->Release();
$rsMain11= null;
// closes the connection, frees up resources, kills all traces
$adoCon->Close();
$adoCon = null;
?>
<div id="footer">
<p>Jane</p>
</div></div></div>
</body>
</html>Jcart | Please use
Code: Select all
andCode: Select all
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]