Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Inserting twice into the database

Featured Replies

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

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?

  • 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

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

  • 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

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.