ivalea Posted October 12, 2006 Share Posted October 12, 2006 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! :) Quote Link to comment Share on other sites More sharing options...
akitchin Posted October 12, 2006 Share Posted October 12, 2006 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.