PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
wsmeyer
Forum Newbie
Posts: 6 Joined: Fri Aug 27, 2004 8:28 pm
Location: Los Angeles
Post
by wsmeyer » Fri Aug 27, 2004 8:28 pm
The code I am modifying is the order administration page of a shopping cart. This portion writes the tracking # to the database and emails the tracking # to the customer. If instead of trying to grab the email address from the database I hard code $to=
wsmeyer@atitec.com ; everything else works perfectly but as shown below the email bounces with no "to"
Code: Select all
if(@$_POSTї"act"]=="tracking"){
do_stock_management(trim($_POSTї"id"]));
if(trim($_POSTї"authcode"]) != "1ZA918R503")
$sSQL = "UPDATE orders set ordExtra2='" . mysql_escape_string(trim($_POSTї"authcode"])) . "',ordStatus=6 WHERE ordID=" . $_POSTї"id"]; mysql_query($sSQL) or print(mysql_error());
mysql_query($sSQL) or die(mysql_error());
$sSQL_t = "SELECT ordEmail FROM orders WHERE ordID=" . $rsї"OrdID"];
$result = mysql_query($sSQL_t) or die(mysql_error());
list($to) = msyql_fetch_row($result);
$tn = "$authcode";
$subject = "Your order has been shipped";
$body = "http://www.chaleur.com/tracking.php?trackno=$tn";
$headers = "From: " . "Chaleur.com" . " <" . "sales@chaleur.com" . ">\r\n" .
"X-Mailer: php";
if (mail($to, $subject, $body, $headers))
{
echo("<p>Message sent!</p>");
}
else
{
echo("<p>Message delivery failed...</p>");
}
Any help would be appreciated!
William.
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Fri Aug 27, 2004 8:58 pm
are you sure $to was filled with something?
wsmeyer
Forum Newbie
Posts: 6 Joined: Fri Aug 27, 2004 8:28 pm
Location: Los Angeles
Post
by wsmeyer » Fri Aug 27, 2004 9:42 pm
I'm not sure what you are asking, when I replace this portion
Code: Select all
$sSQL_t = "SELECT ordEmail FROM orders WHERE ordID=" . $rsї"OrdID"];
$result = mysql_query($sSQL_t) or die(mysql_error());
list($to) = msyql_fetch_row($result);
with $to="
wsmeyer@atitec.com "
it does what I want but of course the email comes to me, I have verified that the email address I want is in the database "ordEmail" but my query is not pulling it.
William.
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Fri Aug 27, 2004 10:00 pm
add this after your fetch call:
and post the results, please.
wsmeyer
Forum Newbie
Posts: 6 Joined: Fri Aug 27, 2004 8:28 pm
Location: Los Angeles
Post
by wsmeyer » Fri Aug 27, 2004 10:26 pm
Code: Select all
if(@$_POSTї"act"]=="tracking"){
do_stock_management(trim($_POSTї"id"]));
if(trim($_POSTї"authcode"]) != "1ZA918R503")
$sSQL = "UPDATE orders set ordExtra2='" . mysql_escape_string(trim($_POSTї"authcode"])) . "',ordStatus=6 WHERE ordID=" . $_POSTї"id"]; mysql_query($sSQL) or print(mysql_error());
mysql_query($sSQL) or die(mysql_error());
$sSQL_t = "SELECT ordEmail FROM orders WHERE ordID=" . $rsї"OrdID"];
$result = mysql_query($sSQL_t) or die(mysql_error());
list($to) = msyql_fetch_row($result);
var_dump($sSQL_t,$to,$rs);
$tn = "$authcode";
$subject = "Your order has been shipped";
$body = "http://www.chaleur.com/tracking.php?trackno=$tn";
$headers = "From: " . "Chaleur.com" . " <" . "sales@chaleur.com" . ">\r\n" .
"X-Mailer: php";
if (mail($to, $subject, $body, $headers))
{
echo("<p>Message sent!</p>");
}
else
{
echo("<p>Message delivery failed...</p>");
}
returns the same result
You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
William.
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Fri Aug 27, 2004 10:38 pm
where's $rs['OrdID'] set?
wsmeyer
Forum Newbie
Posts: 6 Joined: Fri Aug 27, 2004 8:28 pm
Location: Los Angeles
Post
by wsmeyer » Fri Aug 27, 2004 10:56 pm
I've palying with it since posting and have this now
Code: Select all
if(@$_POSTї"act"]=="tracking"){
do_stock_management(trim($_POSTї"id"]));
if(trim($_POSTї"authcode"]) != "1ZA918R503")
echo 'authcode = ' . $_POSTї"authcode"] . '<br>
id = ' . $_POSTї"id"] . '<br>
ordEmail = ' . $rsї"ordEmail"] . '<P>';
$sSQL = "UPDATE orders set ordExtra2='" . mysql_escape_string(trim($_POSTї"authcode"])) . "',ordStatus=6 WHERE ordID=" . $_POSTї"id"];
$result1= mysql_query($sSQL) or die('Query 1:<br />' .mysql_error());
$sSQL_t = "SELECT ordEmail FROM orders WHERE ordID=" . $rsї"id"];
$result = mysql_query($sSQL_t) or die(mysql_error());
list($to) = msyql_fetch_row($result);
$tn = "$authcode";
$subject = "Your order has been shipped";
$body = "http://www.chaleur.com/tracking.php?trackno=$tn";
$headers = "From: " . "Chaleur.com" . " <" . "sales@chaleur.com" . ">\r\n" .
"X-Mailer: php";
if (mail($to, $subject, $body, $headers))
{
echo("<p>Message sent!</p>");
}
else
{
echo("<p>Message delivery failed...</p>");
}
which returns this
authcode = 1458
id = 709
ordEmail =
You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
authcode is the tracking # and id is the ordID number
William.
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Fri Aug 27, 2004 11:03 pm
where is $rs created? why is it $rs['id'] instead of $_POST['id'] ??
wsmeyer
Forum Newbie
Posts: 6 Joined: Fri Aug 27, 2004 8:28 pm
Location: Los Angeles
Post
by wsmeyer » Fri Aug 27, 2004 11:15 pm
hopefully this will clear some of that up
Code: Select all
if(@$_POSTї"act"]=="tracking"){
do_stock_management(trim($_POSTї"id"]));
if(trim($_POSTї"authcode"]) != "1ZA918R503")
$sSQL = "UPDATE orders set ordExtra2='" . mysql_escape_string(trim($_POSTї"authcode"])) . "',ordStatus=6 WHERE ordID=" . $_POSTї"id"];
$result1= mysql_query($sSQL) or die('Query 1:<br />' .mysql_error());
$sSQL_t = "SELECT ordEmail FROM orders WHERE ordID=" . $_POSTї"id"];
$result = mysql_query($sSQL_t) or die(mysql_error());
echo 'authcode = ' . $_POSTї"authcode"] . '<br>
id = ' . $_POSTї"id"] . '<br>
ordEmail = ' . $rsї"ordEmail"] . '<P>';
list($to) = msyql_fetch_row($result);
$tn = "$authcode";
$subject = "Your order has been shipped";
$body = "http://www.chaleur.com/tracking.php?trackno=$tn";
$headers = "From: " . "Chaleur.com" . " <" . "sales@chaleur.com" . ">\r\n" .
"X-Mailer: php";
if (mail($to, $subject, $body, $headers))
{
echo("<p>Message sent!</p>");
}
else
{
echo("<p>Message delivery failed...</p>");
}
returns
authcode = 789
id = 709
ordEmail =
Fatal error: Call to undefined function: msyql_fetch_row() in /home/wsmeyer/public_html/vsadmin/inc/incorders.php on line 479
line 479 is
Code: Select all
list($to) = msyql_fetch_row($result);
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Fri Aug 27, 2004 11:36 pm
mysql_fetch_row.. misspelled
wsmeyer
Forum Newbie
Posts: 6 Joined: Fri Aug 27, 2004 8:28 pm
Location: Los Angeles
Post
by wsmeyer » Sat Aug 28, 2004 12:33 am
I cannot believe how long I have been staring at this and how many different things I tried and it was just a spelling mistake all along!
Thanks for all your help!
William.