I am attempting to move data from one table to another in a script, and am lost somewhere.
I first load the customers data from the orders table, then delete their entry in the orders and carts table. Then write the data I have retreived into another table without the credit card info and such.
I have done a lot of query coding on this site with no problem, but for some reason I seem to missing something very simple here.
Might someone be able to point it out to me? My Brain is about goo at the moment. The following is the error message I am getting, and then after that is the snippet of offending code:
:Err-->
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/.dahli/ans/armynavymarinestore.com/admini/admin.php on line 466
The Code is the entire function. -- Line 466 is marked. It will let me delete everything I want, but cannot add anything to the processed table.
:Code-->
NOTE: $ID is the session ID
function process($ID)
{
// This will read the Order and Cart information, Save the Order info in a File for input into Keystroke.
// And a file for UPS Shipping if applicable. Name, Email Address will be kept in the database for responding to the
// guest and feedback.
// First thing, Load the Client data, and email confirmation of order reception and advise of process status.
$query="select FirstName, SecondName, Addr1, Addr2, Addr3, Addr4, Phone, email, Date from orders where Session=\"$ID\"";
require("../connect.php");
if (!$link = @mysql_connect($db_host, $db_user, $db_pass)) {$DB_ERR="Error Connecting to Host!!"; DB_DED($DB_ERR);}
else { if (!@mysql_select_db($db_name, $link)) {$DB_ERR="Error Connecting to Database at Host!!"; DB_DED($DB_ERR);}
else { if(!$result = @mysql_query($query, $link)) {$DB_ERR="Error Performing Query!"; DB_DED($DB_ERR);}
else { while ($client_info = mysql_fetch_array($result)) // <--- This is Line 466 ###########
{
// First Read the File for the Message //
$message="Greetings.\n\nWe have received your Order, and are processing it now. Please allow 2 to 3 business days for processing. We will notify you once your order has been shipped.\n\n\n\n";
// Then we send it.
mail("$client_info[7]", "Army Navy Store - We have recieved your order", $message , "From:webmaster@armynavymarinestore.com\n");
Echo "Mail Sent...";
// Remove from table orders
$query="delete from orders where session=\"$ID\" limit 1";
require("../connect.php");
if (!$link = @mysql_connect($db_host, $db_user, $db_pass)) {$DB_ERR="Error Connecting to Host!!"; DB_DED($DB_ERR);}
else { if (!@mysql_select_db($db_name, $link)) {$DB_ERR="Error Connecting to Database at Host!!"; DB_DED($DB_ERR);}
else { if(!$result = @mysql_query($query, $link)) {$DB_ERR="Error Performing Query!"; DB_DED($DB_ERR);}}}
// Remove from table carts
$query="delete from carts where session=\"$ID\"";
require("../connect.php");
if (!$link = @mysql_connect($db_host, $db_user, $db_pass)) {$DB_ERR="Error Connecting to Host!!"; DB_DED($DB_ERR);}
else { if (!@mysql_select_db($db_name, $link)) {$DB_ERR="Error Connecting to Database at Host!!"; DB_DED($DB_ERR);}
else { if(!$result = @mysql_query($query, $link)) {$DB_ERR="Error Performing Query!"; DB_DED($DB_ERR);}}}
echo "Order removed from active DBs...";
// Now lets add to the proccesed database
$datestream=(date ("l dS of F Y h:i:s A"));
$query="insert into processing (FirstName, SecondName, Addr1, Addr2, Addr3, Addr4, Phone, email, Date, procdate) values ( \"$client_info[0]\", \"$client_info[1]\", \"$client_info[2]\", \"$client_info[3]\", \"$client_info[4]\", \"$client_info[5]\", \"$client_info[6]\", \"$client_info[7]\", \"$client_info[8]\", \"$datestream\")";
require("../connect.php");
if (!$link = @mysql_connect($db_host, $db_user, $db_pass)) {$DB_ERR="Error Connecting to Host!!"; DB_DED($DB_ERR);}
else { if (!@mysql_select_db($db_name, $link)) {$DB_ERR="Error Connecting to Database at Host!!"; DB_DED($DB_ERR);}
else { if(!$result = @mysql_query($query, $link)) {$DB_ERR="Error Performing Query! Frell!"; DB_DED($DB_ERR);}
else {echo "Contact info moved to Proccessing";}}}
}
}}}
echo "<center>";
echo "<table width=650 cellspacing=0 class=textareaa border=0>";
echo "<tr><td class=nav colspan=4><Font size=2>";
echo "</td></tr>";
echo "<tr><td class=nav colspan=4>";
echo "<hr color=\"#cc9f5e\"></td></tr>";
echo "<tr><td class=nav colspan=4><Font size=2>";
echo "</font></td></tr>";
echo "<tr><td class=nav colspan=4><hr color=\"#cc9f5e\"></td></tr>";
echo "<tr><td class=txtareaa colspan=4>";
}
Any Help would be vastly appreciated.