Please help with this code
Posted: Fri Jan 14, 2005 7:34 pm
Guys I am creating a big shopping cart....
the way the cart is being built might be strange... i am not sure
We have different categories of products... for example.. let say we have televisions... now the TVs have different categories like Plasma, tubes, LCDs and so on...
I created different folders labeled for the TV categories with all the php the files inside that link to one shopping cart...
now I am getting this error..on the CART.PHP file
This is GetRearProj.php File (All files that retrieve the product information are similar)
AND This here is CART.php file
Please advise what the problem might be and what I can do to fix it... thank you...[/quote]
the way the cart is being built might be strange... i am not sure
We have different categories of products... for example.. let say we have televisions... now the TVs have different categories like Plasma, tubes, LCDs and so on...
I created different folders labeled for the TV categories with all the php the files inside that link to one shopping cart...
now I am getting this error..on the CART.PHP file
It does however display the products... but only from whichever category I last added the product from....Warning: extract(): First argument should be an array in C:\Program Files\YellowTip\Htdocs\SP\TMMC\Products\TubeTV\cart.php on line 62
This is GetRearProj.php File (All files that retrieve the product information are similar)
Code: Select all
<?php
session_start();
include ('../conn.inc.php');
$prodid=$_REQUESTї'prodid'];
$query = "SELECT * FROM RearProj WHERE prodnum='$prodid'";
$results = mysql_query($query)
or die(mysql_error());
$row = mysql_fetch_array($results);
extract ($row);
?>
<HTML>
<HEAD>
<TITLE><?php echo $name ?></TITLE>
</HEAD>
<style fprolloverstyle>A:hover {color: red; font-weight: bold}
</style>
<BODY>
<div align="center">
<font face="arial"><h3><center>Select another item <strong><font color="blue"><?php echo $_SESSIONї'user_logged']; ?></font></strong></center></h3>
<blockquote>
<a style="text-decoration: none; color: #0000FF" href="../../Login/user_personal.php"> Edit
Your Account </a>
<a style="text-decoration: none; color: blue" href="../logout.php?action=Logout">
<?php echo "Log out " . $_SESSIONї'name'] . "</a>";?></font></p>
</blockquote>
</font>
</div>
<div align='center'><font face="arial">
<table width='500' cellpadding = '5'>
<tr>
<?php
echo "<td>";
echo "<strong>";
echo $name;
echo "</strong><br>";
echo $proddesc;
echo "<br>";
echo "Product Number: ";
echo $prodnum;
echo "<br>Price: ";
echo $price;
echo "</td>";
?>
</tr>
<tr>
<td><form method="POST" action="add2.php">
Quantity:
<input type="text" name="qty" size="2">
<input type="hidden" name="prodnum" value="<?php echo $prodnum ?>">
<input type="submit" name="Submit" value="Add to cart">
<form method = "POST" action="cart2.php">
<input type="submit" name="Submit" value="View cart">
</form> </form>
</td>
</tr>
</table>
<a style="text-decoration: none; color: #0000FF" href="RearProjShop.php">Back to Rear Projections</a></font> </div>
</BODY>
</HTML>Code: Select all
<?php
session_id();
session_start();
include "../auth_user.inc.php";
//connect to the database
$connect = mysql_connect("localhost", "admin", "asdfgh") or
die ("The connection could not be established with the server.");
mysql_select_db ("TheMixedMediaCompany");
?>
<HTML>
<HEAD>
<TITLE>Lets Go Shopping!</TITLE>
</HEAD>
<BODY>
<p>
<style fprolloverstyle>A:hover {color: red; font-weight: bold}
</style>
</p>
<p align="center">Welcome <strong><font color="blue"><?php echo $_SESSIONї'user_logged']; ?></font></strong><font face="arial">
</font> </p>
<blockquote>
<blockquote>
<p align="center"><font color="#FF0000" face="arial"><a style="text-decoration: none; color: #0000FF" href="../../Login/user_personal.php">Edit
Your Account </a>
<a style="text-decoration: none; color: blue" href="logout.php?action=Logout">
<?php echo "Log out " . $_SESSIONї'name'] . "</a>";?></font></p>
</blockquote>
</blockquote><br><br>
<font face="arial">
<div align="center">
<p>You currently have
<?php
$sessid = session_id();
//display number of products in cart
$query = "SELECT * from carttemp WHERE sess = '$sessid'";
$results = mysql_query($query)
or die (mysql_query());
$rows = mysql_num_rows($results);
echo $rows;
?>
product(s) in your cart.</p>
<table border="1" align="center" cellpadding="5">
<tr>
<td>Quantity</td>
<!--<td>Item Image</td>-->
<td>Item Name</td>
<td>Price Each</td>
<td>Extended Price</td>
<td></td>
<td></td>
<tr>
<?php
while ($row = mysql_fetch_array($results)) {
extract ($row);
$prod = "SELECT * FROM rearProj WHERE prodnum =
'$prodnum'";
$prod2 = mysql_query($prod);
$prod3 = mysql_fetch_array($prod2);
extract ($prod3); //**This is where its causing the problem***
echo "<td><form method = 'POST' action='change2.php'>
<input type='hidden' name='prodnum'
value='$prodnum'>
<input type='hidden' name='sessid'
value='$sessid'>
<input type='hidden' name='hidden'
value='$hidden'>
<input type='text' name='qty' size='2'
value='$quan'>";
echo "</td>";
echo "<td>";
echo "<a style='text-decoration: none; color: #0000FF' href = 'getRearProj.php?prodid=" .
$prodnum ."'>";
echo $name;
echo "</td></a>";
echo "<td align='right'>";
echo $price;
echo "</td>";
echo "<td align='right'>";
//get extended price
$extprice = number_format($price * $quan, 2);
echo $extprice;
echo "</td>";
echo "<td>";
echo "<input type='submit' name='Submit'
value='Change Qty'>
</form></td>";
echo "<td>";
echo "<form method = 'POST' action='delete2.php'>
<input type='hidden' name='prodnum'
value='$prodnum'>
<input type='hidden' name='qty' value='$quan'>
<input type='hidden' name='hidden'
value='$hidden'>
<input type='hidden' name='sessid'
value='$sessid'>";
echo "<input type='submit' name='Submit'
value='Delete Item'>
</form></td>";
echo "</tr>";
//add extended price to total
$total = $extprice + $total;
}
?>
<tr>
<td colspan='4' align='right'>Your total before shipping is:</td>
<td align='right'> <?php echo number_format($total, 2) ?></td>
<td></td>
<td></td>
</tr>
</table>
<form method="POST" action="../checkout.php">
<input type='submit' name='Submit' value='Checkout'>
</form>
<a style="text-decoration: none; color: #0000FF" href="RearProjShop.php">Back to Rear Projection</a> </div>
</font>
</BODY>
</HTML>