Jump to content


Photo

Where's the error? - Please help!


  • Please log in to reply
1 reply to this topic

#1 ivalea

ivalea
  • Members
  • PipPip
  • Member
  • 24 posts

Posted 12 October 2006 - 04:29 AM

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???

$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>';

Thanks in advance for any help you can provide!  :)

#2 akitchin

akitchin
  • Staff Alumni
  • Advanced Member
  • 2,516 posts
  • LocationCalgary, AB, Canada

Posted 12 October 2006 - 06:05 AM

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

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

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users