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
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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.