Check if an order already exists if not create one
I have an issue with a payment gateway. I need to check if an order exists already, if it does i need to use that order id and proceed to the hosted payment page, if it doesnt i need to create it. I have this part to create the order but if it already exists i am getting a duplicate key error which i would expect.
this is the insert if orderID doesnt exist
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO beauSS13_orders (OrderID, CustomerID, OrderDate, Shipping, Discount, Tax, Total) VALUES (%s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['OrderID'], "text"),
GetSQLValueString($_POST['CustomerID'], "int"),
GetSQLValueString($_POST['OrderDate'], "date"),
GetSQLValueString($_POST['Shipping'], "double"),
GetSQLValueString($_POST['Discount'], "double"),
GetSQLValueString($_POST['Tax'], "double"),
GetSQLValueString($_POST['XC_Amount'], "double"));
i found this on the internet
$url_id = mysql_real_escape_string($_GET['id']);
$sql = "SELECT id FROM members WHERE id='$url_id'";
$result = mysql_query($sql);
if(mysql_num_rows($result) >0){
//found
}else{
//not found
}
but need to know how to adapt it to suite my script
