PHP Inserting twice into mysql
Posted: Thu Nov 10, 2011 1:11 pm
Hi Guys,
I am trying to get row from first table and add it to the second table, but the problem I am having is it is getting the row and adding it twice to the second table?
I don;t know what is the error in the code:
Youssef
I am trying to get row from first table and add it to the second table, but the problem I am having is it is getting the row and adding it twice to the second table?
I don;t know what is the error in the code:
Code: Select all
//if the payment approved
if($CpiResultsCode == 0)
{
require_once "*******.php";
// get the information from the unpaid table
$sql = mysql_query("SELECT * FROM ******* WHERE OrderID='$OrderId' LIMIT 1");
$productCount = mysql_num_rows($sql); // count the output amount
//if > 0 begins
if ($productCount > 0)
{
while($row = mysql_fetch_array($sql))
{
// get the information from temporary table
$ShippingCountry = $row["ShippingCountry"];
$ShippingCountry = mysql_real_escape_string($ShippingCountry);
$IP = $row["IP"];
$IP = mysql_real_escape_string($IP);
$Date = $row["Date"];
$Date = mysql_real_escape_string($Date);
}
//insert the payment into the database
$sql = mysql_query("INSERT INTO ****** (OrderID, BillingFirstName, BillingLastName, ShopperEmail, BillingAddress1 ,BillingAddress2, BillingCity, BillingCounty, BillingPostal, BillingCountry, ShippingFirstName, ShippingLastName, ShippingAddress1, ShippingAddress2, ShippingCity, ShippingCounty, ShippingPostal, ShippingCountry, IP, Date) VALUES ('$OrderId', '$BillingFirstName', '$BillingLastName', '$ShopperEmail', '$BillingAddress1', '$BillingAddress2','$BillingCity', '$BillingCounty','$BillingPostal', '$BillingCountry', '$ShippingFirstName','$ShippingLastName', '$ShippingAddress1', '$ShippingAddress2', '$ShippingCity', '$ShippingCounty' , '$ShippingPostal', '$ShippingCountry', '$IP', '$today' )");
}
}