Warning: mysql_fetch_object(): supplied argument is not a v
Posted: Sun Apr 17, 2011 3:51 pm
hi,i face error like this Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in these sentence and
actually i want put customer detail and total amount by retrieve 1 row which match user id and order id and put detail of product which the user buy..
so i use if ($data = mysql_fetch_object($result)) to match 1 row and while($row=mysql_fetch_object($result1)) to put all the product bought by the user...
but i failed to put these..can anyone help me to correct these code??thanks in advance..
Code: Select all
if ($data = mysql_fetch_object($result))
{Code: Select all
<?php
while($row=mysql_fetch_object($result1))
{
?>
so i use if ($data = mysql_fetch_object($result)) to match 1 row and while($row=mysql_fetch_object($result1)) to put all the product bought by the user...
but i failed to put these..can anyone help me to correct these code??thanks in advance..
Code: Select all
<?php
session_start();
require_once 'config.php' ;
require_once 'application.php' ;
$cartid=$_REQUEST['cartid'];
$id = $_SESSION['id'];
$o_orderid = $_SESSION['o_orderid'];
$d_orderid = $_SESSION['d_orderid'];
$username = $_SESSION['username'];
$pid=$_REQUEST['pid'];
$pname=$_REQUEST['pname'];
$uprice=$_REQUEST['uprice'];
$quantity=$_REQUEST['quantity'];
$total = $_SESSION['total'];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="style.css" rel="stylesheet" type="text/css">
<title>::Order List::</title>
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;"/>
<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
</head>
<body>
<table width="952px" border="0" cellspacing="0" cellpadding="0" valign="top" align="center">
<tr>
<td align="center"><?php include "header.php"; ?></td>
</tr>
<tr><td><img src="picture/purple_line.jpg" /></td></tr>
<tr>
<td><table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="300px" height="600px" valign="top" align="center"> <?php include "menu.php";?>
</td>
<td width="12px"> </td>
<td width="630px"background="picture/content1.png" style="background-repeat:no-repeat;" valign="top"><table width="100%" border="0">
<tr>
<td><table width="100%" border="0" align="right">
<tr>
<td width="28%"> </td>
<td width="38%"><img src="picture/icon_cart.jpg" /></td>
</tr>
</table></td>
</tr>
<tr>
<td>
<?php
$query = "SELECT * FROM orders WHERE o_orderid=$o_orderid AND id = $id";
$result = mysql_query($query);
if ($data = mysql_fetch_object($result))
{
?>
<div align="center">
<table bgcolor="#FFFFFF">
<tr><td bgcolor="#eeee76"><font color="#000000"class="txt_black">Order ID:</font></td>
<td><?php echo $data->o_orderid;?></td>
<input type="hidden" name="id" value="<?php echo $data->id ?>">
</tr>
<tr>
<td bgcolor="#eeee76"><font color="#000000"class="txt_black">Name:</font></td>
<td><?php echo $data->name; ?></td>
</tr>
<tr>
<td bgcolor="#eeee76"><div align="justify"><font color="#000000"class="txt_black">Contact No: </font></div></td>
<<td><?php echo $data->phone; ?></td>
</tr>
<tr>
<td bgcolor="#eeee76"><div align="justify"><font color="#000000"class="txt_black">Delivery Address: </font></div></td>
<td><?php echo $data->address; ?></td>
</tr>
<tr>
<td bgcolor="#eeee76"><div align="justify"><font color="#000000"class="txt_black">Postcode: </font></div></td>
<td><?php echo $data->postcode; ?></td>
</tr>
<tr>
<td bgcolor="#eeee76"><div align="justify"><font color="#000000"class="txt_black">City: </font></div></td>
<td><?php echo $data->city; ?></td>
</tr>
<tr>
<td bgcolor="#eeee76"><label for="state"class="txt_black">State</label></td>
<td><?php echo $data->state; ?></td>
</tr></table>
</div> <?php } ?></td></tr>
<tr>
<td>
<div align="center"><?php
$query1 = "SELECT * FROM detail WHERE id=$id AND d_orderid=$d_orderid ";
$result1 = mysql_query($query1);
?>
<table border="1"bgcolor="#FFFFFF" cellpadding="0" cellspacing="0" width="500px">
<tr align="center">
<td width="200px" bgcolor="#eeee76"><font color="#000000"class="txt_black">Item Name</font></td>
<td width="100px" bgcolor="#eeee76"><font color="#000000"class="txt_black">Unit Price(RM)</font></td>
<td width="100px" bgcolor="#eeee76"><font color="#000000"class="txt_black">Quantity</font></td>
<td width="100px" bgcolor="#eeee76"><font color="#000000"class="txt_black">Total Price(RM)</font></td>
</tr>
<?php
while($row=mysql_fetch_object($result1))
{
?>
<tr><input type="hidden" name="id" value="<?php echo $row->id ?>">
<td align="center"width="100px"> <font color="#000000"><?php echo $row->d_pname;?></font></td>
<td align="center" width="100px"><font color="#000000"><nobr>RM
<?php echo $row->d_price;?> </nobr></font></td>
<td width="100px" align="center"><font color="#000000"><nobr>
<?php echo $row->d_quantity;?> </nobr></font></td>
<?php
$totalup = $row->d_price * $row->d_quantity;
?>
<td width="100px"><font color="#000000"><nobr>RM <?php echo $totalup;?>
</nobr></font></td>
</tr>
<tr><td></td><?php
$total += $totalup;
$_SESSION["total"] = $total;
$totalQuantity += $row->d_quantity; ?> <?php } ?>
<td width="180" height="50"><div align="center"><font color="#000000"class="txt_black">Total
Amount :</font></div></td>
<td width="60" align=center><font color="#000000"> <?php echo $totalQuantity;?></font>
</td>
<td width="60"><font color="#000000">RM<?php echo $_SESSION["total"];?></font></td>
</tr>
<tr>
<td></td><td align ="center"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="105" height="21">
<param name="movie" value="button3.swf" />
<param name="quality" value="high" />
<param name="base" value="." />
<embed src="button3.swf" base="." quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="105" height="21" ></embed>
</object></td>
</tr>
</table>
</div></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td> </td>
</tr>
</table>
</body>
</html>