proctk Posted August 29, 2007 Share Posted August 29, 2007 HI How can I tell if a query is empty I need to test this $get_buddys = mysql_query($query_get_buddys) or die ("Invalid query". mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/67171-empty-query/ Share on other sites More sharing options...
Hypnos Posted August 29, 2007 Share Posted August 29, 2007 If a query string is empty, or there were 0 results? mysql_num_rows, if you want the latter. Quote Link to comment https://forums.phpfreaks.com/topic/67171-empty-query/#findComment-336915 Share on other sites More sharing options...
proctk Posted August 29, 2007 Author Share Posted August 29, 2007 yeh I tried that but something weird is happening, it always returning a result but the out but does not match the number of found rows Quote Link to comment https://forums.phpfreaks.com/topic/67171-empty-query/#findComment-336922 Share on other sites More sharing options...
mmarif4u Posted August 29, 2007 Share Posted August 29, 2007 Can u post ur code. Quote Link to comment https://forums.phpfreaks.com/topic/67171-empty-query/#findComment-336926 Share on other sites More sharing options...
proctk Posted August 29, 2007 Author Share Posted August 29, 2007 this code was created with the support on this forum from another post. It returns a result all the time using the mysql_sql_num_rows regardless if the out put is blank thanks <?php $query_get_buddys = ("SELECT * FROM buddylink b LEFT JOIN users u ON b.buddy_id = u.user_id AND month(u.DOB) ='$month' WHERE b.owner_id = '$id'"); $get_buddys = mysql_query($query_get_buddys) or die ("Invalid query". mysql_error()); while($buddyBirthdays = mysql_fetch_assoc($get_buddys)){ //Get child birth day $buddyBirthDay = $buddyBirthdays['DOB']; $buddyBirthDay_array = explode("-",$buddyBirthDay); $buddy_day_num = $buddyBirthDay_array[2]; ?> <?php if(!empty($buddyBirthdays['DOB'])){?> <p class="bdayText"> <?php echo $buddy_day_num; ?> - <a class="bdayLink" href="../profile.php?id=<?php echo $buddyBirthdays['user_id'] ?>"><?php echo $buddyBirthdays['first_name'].' '.$buddyBirthdays['last_name']; ?></a>(<?php echo birthday($buddyBirthdays['DOB']) ?>)</p> <?php }else{}?> <?php } ?> <?php $query_get_buddys = ("SELECT * FROM buddylink b LEFT JOIN users u ON b.buddy_id = u.user_id AND month(u.DOB) ='2' WHERE b.owner_id = '$user_id'"); $get_buddys = mysql_query($query_get_buddys) or die ("Invalid query". mysql_error()); while($buddyBirthdays = mysql_fetch_assoc($get_buddys)){ //Get child birth day $buddyBirthDay = $buddyBirthdays['DOB']; $buddyBirthDay_array = explode("-",$buddyBirthDay); $buddy_day_num = $buddyBirthDay_array[2]; ?> <?php if(!empty($buddyBirthdays['DOB'])){?> <p class="bdayText"> <?php echo $buddy_day_num; ?> - <a class="bdayLink" href="../profile.php?id=<?php echo $buddyBirthdays['user_id'] ?>"><?php echo $buddyBirthdays['first_name']. ' '.$buddyBirthdays['last_name']; ?></a>(<?php echo birthday($buddyBirthdays['DOB']) ?>)</p> <?php }else{}?> <?php } ?> Quote Link to comment https://forums.phpfreaks.com/topic/67171-empty-query/#findComment-336953 Share on other sites More sharing options...
mmarif4u Posted August 29, 2007 Share Posted August 29, 2007 try to use mysql_num_rows. i did not see any of that using in ur query. Quote Link to comment https://forums.phpfreaks.com/topic/67171-empty-query/#findComment-336957 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.