laszlof Posted July 14, 2010 Share Posted July 14, 2010 Hey, I'm having a little trouble with an addon I'm working on. I cant seem to get mysql queries to work properly within some action hook code. Does anyone have any ideas? <?php function verify_affiliate_coupon($vars) { if (isset($_SESSION['cart']['promo'])) { error_log("PROMO CODE SET IN CART!"); $promocode = $_SESSION['cart']['promo']; $sql = "SELECT aff_id FROM `affcoupons` WHERE coupon='$promocode'"; $data = mysql_query($sql); if (mysql_num_rows($data) > 0) { while ($row = mysql_fetch_array($data)) { $affid = $row[0]; } error_log("AFFILIATE ID FOUND"); $_COOKIE['WHMCSAffiliateID'] = $affid; } } } add_hook("PreShoppingCartCheckout",1,"verify_affiliate_coupon",""); ?> Its throwing back an error that says the $data is not a valid mysql resource for mysql_num_rows. If I remove the row count checking, it tells me the same thing for mysql_fetch_array. Anyone have any clues? 0 Quote Link to comment Share on other sites More sharing options...
laszlof Posted July 15, 2010 Author Share Posted July 15, 2010 Got it. 0 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.