Lassie Posted December 25, 2006 Share Posted December 25, 2006 i'm tying to establish that my function is returning the right values, but my de bug line fails to print.Can anyone help please?code isfunction display_dl_link($cart,$product_id){// query database for all details for a particular book if (!$product_id || $product_id=='') return false; $connection = db_connect(); $query = "select dl_link from products where product_id='$product_id'"; $result = mysql_query($query); if (!$result) return false; while ($row = mysql_fetch_assoc($result)){ echo $row['dl_link'];//print to establish record pulled from db}}Thanks,lassie. Link to comment https://forums.phpfreaks.com/topic/31827-de-bug-problem/ Share on other sites More sharing options...
Psycho Posted December 25, 2006 Share Posted December 25, 2006 There are two things to checl. 1) Is your query causing an error and 2) is it returning any results.Try this:[code]<?phpfunction display_dl_link($cart,$product_id) {// query database for all details for a particular book if (!$product_id || $product_id=='') { return false; } $connection = db_connect(); $query = "select dl_link from products where product_id='$product_id'"; $result = mysql_query($query); if (!$result) { mysql_error(); return false; } if (mysql_num_rows($result)==0) { echo "There were 0 results"; } else { while ($row = mysql_fetch_assoc($result)){ echo $row['dl_link'];//print to establish record pulled from db } }}?>[/code] Link to comment https://forums.phpfreaks.com/topic/31827-de-bug-problem/#findComment-147580 Share on other sites More sharing options...
Lassie Posted December 26, 2006 Author Share Posted December 26, 2006 Thanks for that it worked just fine.lassie Link to comment https://forums.phpfreaks.com/topic/31827-de-bug-problem/#findComment-148042 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.