Hi all,
im new 2 all this tring 2 work this 1 out but is not workin. Can u chek this and tell me why this does't enter customer and order details into mysql:
[php]
<?php
$xn = $HTTP_POST_VARS['n'];
$xd = $HTTP_POST_VARS['d'];
$xc = $HTTP_POST_VARS['c'];
$xq = $HTTP_POST_VARS['q'];
$xf = $HTTP_POST_VARS['f'];
$hostname_local = "localhost";
$database_local = "database";
$username_local = "username";
$password_local = "password";
$local = mysql_pconnect($hostname_local, $username_local, $password_local) or die(mysql_error());
mysql_select_db($database_local, $local);
$sql = "SELECT `id` FROM `customers` WHERE bname='".$HTTP_POST_VARS['BName']." and baddress='".$HTTP_POST_VARS['BStreet'];
$Recordset1 = mysql_query($sql, $local);
$id1 = mysql_result($Recordset1,0,"id");
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
if ($totalRows_Recordset1 > 0) {$sql = "INSERT INTO `customers` ( `id` , `bname` , `baddress` , `bcity` , `bstate` , `bzip` , `bcountry` ,
`bphone` , `bfax` , `bemail` , `sname` , `saddress` , `scity` , `sstate` , `szip` , `scountry` , `sphone` , `sfax` ) VALUES ( '', '".
$HTTP_POST_VARS['BName']."', '".$HTTP_POST_VARS['BStreet']."', '".$HTTP_POST_VARS['BCity']."',
'".$HTTP_POST_VARS['BState']."', '".$HTTP_POST_VARS['BZip']."', '".$HTTP_POST_VARS['BCountry']."', '".$HTTP_POST_VARS['BPhone']."',
'".$HTTP_POST_VARS['BFax']."', '".$HTTP_POST_VARS['BEmail']."', '".$HTTP_POST_VARS['Name']."', '".$HTTP_POST_VARS['Street']."',
'".$HTTP_POST_VARS['City']."', '".$HTTP_POST_VARS['State']."', '".$HTTP_POST_VARS['Zip']."', '".$HTTP_POST_VARS['Country']."',
'".$HTTP_POST_VARS['Phone']."', '".$HTTP_POST_VARS['Fax']."' )";
$Recordset1 = mysql_query($sql, $local);
}
for ($i =0; $i< $HTTP_POST_VARS['orderedtotal'];$i++){
if ($xn[$i] != "" ){$my_body .= "Product ".$xn[$i] ." ".$xd[$i]." @ cost " .$xc[$i]. " with ".$xq[$i] . " ordered\n";}
//insert into the order database
$sql = "INSERT INTO `orders` VALUES ( '','$id1', '$my_body', '".$HTTP_POST_VARS['total']."', '".$HTTP_POST_VARS['shiptotal']."', '".date("F j, Y, g:i a")."' )";
$Recordset1 = mysql_query($sql, $local);}
$my_body = "";
error_reporting(E_ALL ^ (E_NOTICE));
$my_body = "";
$MailFrom = "From:". $HTTP_POST_VARS['BEmail']."\n";
$my_body .= "****************************************************************\n";
$my_body .= "The Order is as follows (the number shown is the quantity ordered)\n";
$my_body .= "Ordered on ".date("F j, Y, g:i a") ."\n";
$my_body .= "****************************************************************\n";
for ($i =0; $i< $HTTP_POST_VARS['orderedtotal'];$i++){ if ($xn[$i] != "" )$my_body23 .= "Product ".$xn[$i] ." ".$xd[$i]." @ cost " .$xc[$i]. " with ".$xq[$i] . " ordered\n";}
$my_body .= strip_tags($my_body23);
$my_body .= "************************************\n";
$my_body .= "Sales Tax= " . $HTTP_POST_VARS['saletotal'] . "\n";
$my_body .= "Total Cost:= " . $HTTP_POST_VARS['total'] . "\n";
$my_body .= "****************************************************************\n";
$my_body .= "****************************************************************\n";
$my_body .= "Shipping Information\n";
$my_body .= "****************************************************************\n";
if( $HTTP_POST_VARS['SameAsBill'] ){$my_body .= "Same as Billing Address". "\n";}
$my_body .= "Name= " . $HTTP_POST_VARS['Name'] . "\n";
$my_body .= "Address= " . $HTTP_POST_VARS['Street'] . "\n";
$my_body .= "City= " . $HTTP_POST_VARS['City'] . "\n";
$my_body .= "State= ". $HTTP_POST_VARS['State']. "\n";
$my_body .= "Zip= " . $HTTP_POST_VARS['Zip'] . "\n";
$my_body .= "Country=" . $HTTP_POST_VARS['Country'] . "\n";
$my_body .= "Phone= " . $HTTP_POST_VARS['Phone']. "\n";
$my_body .= "Fax= " . $HTTP_POST_VARS['Fax']. "\n";
$my_body .= "****************************************************************\n";
$my_body .= "Users Comments= " . $HTTP_POST_VARS['theComments']. "\n";
$my_body .= "****************************************************************\n";
$my_body .= "Billing Information\n";
$my_body .= "****************************************************************\n";
$my_body .= "Name= " . $HTTP_POST_VARS['BName'] . "\n";
$my_body .= "Street= " . $HTTP_POST_VARS['BStreet'] . "\n";
$my_body .= "City= " . $HTTP_POST_VARS['BCity'] . "\n";
$my_body .= "State= ". $HTTP_POST_VARS['BState']. "\n";
$my_body .= "Zip= " . $HTTP_POST_VARS['BZip'] . "\n";
$my_body .= "Country=" . $HTTP_POST_VARS['BCountry']. "\n";
$my_body .= "Phone= " . $HTTP_POST_VARS['BPhone'] . "\n";
$my_body .= "Fax= " . $HTTP_POST_VARS['BFax'] . "\n";
$my_body .= "email= " . $HTTP_POST_VARS['BEmail'] . "\n";
$my_body .= "Company= " . $HTTP_POST_VARS['BCompany'] . "\n";
$my_body .= "Payment Method= " . $HTTP_POST_VARS['Bill_Type'] . "\n";
$my_body .= "Credit Card Number= " . $HTTP_POST_VARS['CCnumber'] . "\n";
$my_body .= "Credit Card Expiration= " . $HTTP_POST_VARS['CCdate'] . "\n";
$my_body .= "Credit Card Security Code= " . $HTTP_POST_VARS['CCpass'] . "\n";
$my_body .= "****************************************************************\n";
$my_body .= "This Order was created using eOrdering Professional by LAJ Design\n";
$my_body .= "****************************************************************\n";
mail("admin@mysite.com","order","$my_body", "$MailFrom" );
?>
[/php]
[html]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/1998/REC-html40-19980424/loose.dtd">
<html>
<head>
<title>Insert title</title>
<META HTTP-EQUIV="content-type" CONTENT="text/html; charset=utf-8">
</head>
<body class="BodyHtml" bgcolor="#FFFFFF" text="#000000" link="#000000" vlink="#000000" Alink="#000000">
<div align="center">
<p>
<SCRIPT language="JavaScript" SRC="includes/above.js"></SCRIPT>
</div>
<br>
<p align="center">[/html][php]<?php
$my_body1 = "";
$my_body1 .= "Ordered on ".date("F j, Y, g:i a") ."\n"."<br>"."<br>";
for ($i =0; $i< $HTTP_POST_VARS['orderedtotal'];$i++){if ($xn[$i] != "" )$my_body31 .= "Product ".$xn[$i] . " ".$xd[$i]." @ cost ". $xc[$i]. " with ".$xq[$i] . " ordered"."\n<br>";}
print $my_body1. str_replace( "\\\"", "\"",$my_body31);
?>[/php][html]<br><br> Thank you for your order!<br>We will be contacting you to confirm.<br>In five seconds you will be redirected to the main page.<br>If not then <a href="index.php">Click Here</a>
<div align="center">
<p>
<SCRIPT language="JavaScript" SRC="includes/below.js"></SCRIPT>
</p>
<br>
<table class="LogoTable" border= "1" width="250" align="center"> <tr><td><a href="<A href="http://www.lajdesignsw.com"><img">http://www.lajdesignsw.com"><img src="wcreated.jpg" width="250" height="75" border="0" ></a></td>
</tr> </table>
<p> </p>
</div>
</body>
</html>
[/html]
I'm having error's:
Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /path 2/process.php on line 29
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /path 2/process.php on line 31