1)加入数据怎么用mysql_fetch_array ?2)Supplied argument is not a valid MySQL result resource in --检查SQL语法是否错误,
谢谢唠叨, yiyingtian(一小刀)(只知灌水,不搞帮派), eagle_gui(凉开水)诸兄: 下面是confirmorder.php的代码,我是从国外出版社的网站上下载的,应该没问题,可能是我的php,mysql or apache 之间配合的问题,想请你们提示一下那方面的问题的。 <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head><body bgcolor="#FFFFFF" text="#000000"> <p> </p> <hr> <table width="950" border="0" align="center" cellspacing="1" cellpadding="3"> <tr> <td width="85%" height="229"> <form name="form2" method="post" action="viewshoppingcart.php"> <table width="100%" border="5" align="center" cellspacing="0" cellpadding="3"> <tr bgcolor=#cccccc> <td ><center><b>Order Confirmed</b></center></td> </tr> <tr> <td> <?php $database="books"; $hostname=""; $dbusername="root"; $dbpassword="";$connect=mysql_connect($hostname,$dbusername,$dbpassword); $dbselect=mysql_select_db($database);$query="select productid from neworder where customerid='".$customerid."'"; $result=mysql_query($query); if(!($row=mysql_fetch_array)) { die("your shopping cart is empty!"); } if(!isset($total)) { die("Shopping cart amount is zero !"); } if(empty($total)) { die("Shopping cart amount is zero !"); } $query="select MAX(orderid) as orderid from orders"; $result=mysql_query($query); if($row=mysql_fetch_array($result)) { $neworderid=++$row["orderid"]; } $dt=getdate(); $dateformat=$dt["year"]."-".$dt["mon"]."-".$dt["mday"];$query="INSERT into orders VALUES('".$neworderid."','".$customerid."','".$dateformat."','".$total."','Pending')"; $result=mysql_query($query); if (!($result)) { die("Order entry failed!"); }$query="select productid from neworder where customerid='".$customerid."'"; $result=mysql_query($query); while($row=mysql_fetch_array($result)) { $query2 = "INSERT into products_ordered VALUES('','".$row["productid"]."','".$neworderid."')"; $result2=mysql_query($query2);if (!($result2)) { die("Products entry for this order failed!"); }
} $query="delete from neworder where customerid='".$customerid."'"; $result=mysql_query($query); if(!($result)) { die("Shopping cart could not be trashed!"); } else { echo "<br><b>Congratulations ! Your order has been successfully sent for processing.</b><br>"; echo "An email will be sent to you with payment options after your order has been reviewed by the administrator."; } ?> </td> </tr> </table> <?php echo "To return to the website <a href=\"mainpage.php?customerid=".$customerid."\">click here!</a></td>";
?> <p> </p> <p> </p> </body> </html>
if(!($row=mysql_fetch_array))//此处有错。 { die("your shopping cart is empty!"); }mysql_fetch_array没有带参数的错误。 mysql_fetch_array($r)
yiyingtian(一小刀)(只知灌水,不搞帮派),
eagle_gui(凉开水)诸兄:
下面是confirmorder.php的代码,我是从国外出版社的网站上下载的,应该没问题,可能是我的php,mysql or apache 之间配合的问题,想请你们提示一下那方面的问题的。
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head><body bgcolor="#FFFFFF" text="#000000">
<p> </p>
<hr>
<table width="950" border="0" align="center" cellspacing="1" cellpadding="3">
<tr>
<td width="85%" height="229">
<form name="form2" method="post" action="viewshoppingcart.php">
<table width="100%" border="5" align="center" cellspacing="0" cellpadding="3">
<tr bgcolor=#cccccc>
<td ><center><b>Order Confirmed</b></center></td>
</tr>
<tr>
<td>
<?php
$database="books";
$hostname="";
$dbusername="root";
$dbpassword="";$connect=mysql_connect($hostname,$dbusername,$dbpassword);
$dbselect=mysql_select_db($database);$query="select productid from neworder where customerid='".$customerid."'";
$result=mysql_query($query);
if(!($row=mysql_fetch_array))
{
die("your shopping cart is empty!");
}
if(!isset($total))
{
die("Shopping cart amount is zero !");
}
if(empty($total))
{
die("Shopping cart amount is zero !");
}
$query="select MAX(orderid) as orderid from orders";
$result=mysql_query($query);
if($row=mysql_fetch_array($result))
{
$neworderid=++$row["orderid"];
} $dt=getdate();
$dateformat=$dt["year"]."-".$dt["mon"]."-".$dt["mday"];$query="INSERT into orders VALUES('".$neworderid."','".$customerid."','".$dateformat."','".$total."','Pending')";
$result=mysql_query($query);
if (!($result))
{
die("Order entry failed!");
}$query="select productid from neworder where customerid='".$customerid."'";
$result=mysql_query($query);
while($row=mysql_fetch_array($result))
{
$query2 = "INSERT into products_ordered VALUES('','".$row["productid"]."','".$neworderid."')";
$result2=mysql_query($query2);if (!($result2))
{
die("Products entry for this order failed!");
}
} $query="delete from neworder where customerid='".$customerid."'";
$result=mysql_query($query);
if(!($result))
{
die("Shopping cart could not be trashed!");
}
else
{
echo "<br><b>Congratulations ! Your order has been successfully sent for processing.</b><br>";
echo "An email will be sent to you with payment options after your order has been reviewed by the administrator.";
}
?>
</td>
</tr>
</table>
<?php
echo "To return to the website <a href=\"mainpage.php?customerid=".$customerid."\">click here!</a></td>";
?>
<p> </p>
<p> </p>
</body>
</html>
{
die("your shopping cart is empty!");
}mysql_fetch_array没有带参数的错误。
mysql_fetch_array($r)