Jump to content

Where's the error? - Please help!


ivalea

Recommended Posts

Hi - I'm trying to run a query that first checks to see if a customer has purchased a certain product and then if they have add them to a table in the db and print out a success message.  I swore I had this working a couple of days ago - thought I'd test it again today and now it's not only NOT adding the customer to the table but there's no message either.  Can you spot the error - maybe i've just been looking at it too long???

[code]
$products = $cart->get_products();
$anycourse =0;
for ($i=0, $n=sizeof($products); $i<$n; $i++)
  {
$val=mysql_fetch_array( mysql_query("select  pd.products_description, p.products_model from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$products[$i]['id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'"));

if ($val = 'CBT-0100'){
$query = "select customers_email_address from customers where customers_id = '" . (int)$customer_id . "'";
$result = mysql_query ($query);
$email=mysql_result($result,"customers_email_address");
if ($result){
$query = "INSERT INTO students (students_id, customers_id, students_pmodel, students_email, students_mod1, students_mod2, students_mod3) values ('', '$customer_id', '$model', '$email', '', '', '')";
$result = mysql_query ($query);
if ($result) {
$anycourse = 1;
}else{
echo 'Could not add customer to db';
}
}
}

}//end for
if ($anycourse == 1)
    echo '<p>Thank you for enrolling in our online course.  To login to your course please go to "My Account".</p>';
[/code]

Thanks in advance for any help you can provide!  :)
Link to comment
https://forums.phpfreaks.com/topic/23724-wheres-the-error-please-help/
Share on other sites

quickest way to check for query errors?  add die clauses to all of your query executions:

[code]$var = mysql_query($query) or die ("problem with [$query]: ".mysql_error());[/code]

change them to include those clauses and see what MySQL spits back at you.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.