Hey Having a little problem.. I have say, page.php with this code: get_coupon_info($_GET['cid']); PHP: page.php also includes functions.php, one of the functions is get_coupon_info: function get_coupon_info($id) { $query = mysql_query("SELECT * FROM coupons, categories WHERE coupons.coupon_category=categories.category_id AND coupon_id = '" . mysql_real_escape_string($id) . "'") or die(mysql_error()); $row = mysql_fetch_array($query); } PHP: Now, as you can see, I'm trying to pull all the stuff within functions.php to keep page.php tidy, however. When I use something like $row['field'] in page.php, it's empty. Is that because what I'm trying to do is not possible and if so what other solution is there? Or is it because I have a slight error somewhere, all help appreciated.
a simple solution is : function get_coupon_info($id) { $query = mysql_query("SELECT * FROM coupons, categories WHERE coupons.coupon_category=categories.category_id AND coupon_id = '" . mysql_real_escape_string($id) . "'") or die(mysql_error()); $row = mysql_fetch_array($query); return $row; /// newly added code } Page.php $row = get_coupon_info($_GET['cid']); /// get the result in page.php code