sangoku Posted March 31, 2010 Share Posted March 31, 2010 how can i bypass when a query returns an empty result but that result is fetched by a for each loop mean the warning mean this: foreach (mysql_fetch_array($resultSql) as $row){ $result[] = $row; } Quote Link to comment https://forums.phpfreaks.com/topic/197177-how-to-bypass-a-warning/ Share on other sites More sharing options...
trq Posted March 31, 2010 Share Posted March 31, 2010 if (mysql_num_rows($resultSql)) { foreach (mysql_fetch_array($resultSql) as $row){ $result[] = $row; } } You are aware however that this will not loop through all results in your query? Just all fields in the single result. Quote Link to comment https://forums.phpfreaks.com/topic/197177-how-to-bypass-a-warning/#findComment-1034982 Share on other sites More sharing options...
oni-kun Posted March 31, 2010 Share Posted March 31, 2010 Yes, you should rethink your logic and use the tried and true methods available if you cannot figure out how to loop it like so. Quote Link to comment https://forums.phpfreaks.com/topic/197177-how-to-bypass-a-warning/#findComment-1034985 Share on other sites More sharing options...
sangoku Posted March 31, 2010 Author Share Posted March 31, 2010 O boy i need straight answers... that happens when by chance there is no match in the db.... usually there are more than one.... AND i dont want notifications Quote Link to comment https://forums.phpfreaks.com/topic/197177-how-to-bypass-a-warning/#findComment-1034994 Share on other sites More sharing options...
sangoku Posted March 31, 2010 Author Share Posted March 31, 2010 noo need foun the answer.... if(mysql_num_rows($resultSql)){ foreach (mysql_fetch_array($resultSql) as $row){ $result[] = $row; } }else{ $result = array(); } num rows is a good one XD Quote Link to comment https://forums.phpfreaks.com/topic/197177-how-to-bypass-a-warning/#findComment-1034997 Share on other sites More sharing options...
trq Posted March 31, 2010 Share Posted March 31, 2010 Again though.... You are aware however that this will not loop through all results in your query? Just all fields in the single result. Quote Link to comment https://forums.phpfreaks.com/topic/197177-how-to-bypass-a-warning/#findComment-1035003 Share on other sites More sharing options...
sangoku Posted April 1, 2010 Author Share Posted April 1, 2010 :'( :-\ Sorry to tell you but I know exactly what i am doing. 4. year IT engineering...... I only ask when i dont know how to do what i wana do..... Quote Link to comment https://forums.phpfreaks.com/topic/197177-how-to-bypass-a-warning/#findComment-1035010 Share on other sites More sharing options...
oni-kun Posted April 1, 2010 Share Posted April 1, 2010 :'( :-\ Sorry to tell you but I know exactly what i am doing. 4. year IT engineering...... I only ask when i dont know how to do what i wana do..... Go complain to your IT tech instructor about the poor material he has taught. Quote Link to comment https://forums.phpfreaks.com/topic/197177-how-to-bypass-a-warning/#findComment-1035011 Share on other sites More sharing options...
ignace Posted April 1, 2010 Share Posted April 1, 2010 if (mysql_num_rows($resultSql)) { foreach (mysql_fetch_array($resultSql) as $row){ $result[] = $row; } } Are you sure this is what you want: $result[] = 'username'; $result[] = 'e-mail'; $result[] = 'password'; Or are you after: $result[] = array('username', 'e-mail', 'password'); $result[] = array('username2', 'e-mail2', 'password2'); .. Quote Link to comment https://forums.phpfreaks.com/topic/197177-how-to-bypass-a-warning/#findComment-1035202 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.