November 10, 201114 yr 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: //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' )"); } } Youssef
November 10, 201114 yr I don't have an answer to your question. But out of curiosity, why do you need to use real_escape if you're selecting from your own DB?
November 10, 201114 yr Author I don't have an answer to your question. But out of curiosity, why do you need to use real_escape if you're selecting from your own DB? Thank you for your reply. No idea why I just use it every where So no idea why this happening. Youssef
November 10, 201114 yr Thank you for your reply. No idea why I just use it every where So no idea why this happening. Youssef Lol before you start creating web apps you need to learn why you are using things places anyways mysql_real_escape_string as best practice only needs to be used in the query it self not when your already ready to display stuff
November 10, 201114 yr Author For the mysql_real_escape_string I know that you use it before inserting data into the database Escapes special characters in a string for use in an SQL statement , I found the error, actually it is not an error, I am using HSPC payment solution and I am reading in there integration guide and they say this: For a completed transaction the transaction result data is provided twice. They are sending it twice into the database from there system Thank you again guys. Youssef
November 10, 201114 yr Escapes special characters in a string for use in an SQL statement , Edited November 10, 201114 yr by webdesigner93
Create an account or sign in to comment