Jump to content


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


Where's the error? - Please help!

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

$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);
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;
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!  :)

Share this post

Link to post
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.

Share this post

Link to post
Share on other sites


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.