richarro1234 Posted February 14, 2009 Share Posted February 14, 2009 hey there, im trying to cut down on the size of my database by checking for a users id in 2 collums of a database. here is the code i have but for some reason it doesnt work? <?php $query12=" SELECT * FROM friends WHERE myid='$urid' and friendsid='$urid' LIMIT 5"; $result=mysql_query($query12) or die ('Error: '.mysql_error ()); $num=mysql_numrows($result) or die ('Error: '.mysql_error ()); $i=0; while ($i < $num) { $myid=mysql_result($result,$i,"myid"); $friendsid=mysql_result($result,$i,"friendsid"); $query10 = mysql_query("SELECT * from users WHERE id = $friendsid " ); while ($fr = mysql_fetch_array($query10)) { $friendspic = $fr['picture']; $friendsname = $fr['username']; } ?> that just comes back as "Error:" and doesnt show a message or anything. Can someone please tell me how i can get this to work. Thanks Rich Quote Link to comment https://forums.phpfreaks.com/topic/145197-how-do-i-check-2-fields/ Share on other sites More sharing options...
DeanWhitehouse Posted February 14, 2009 Share Posted February 14, 2009 get rid of the die on the mysql_num_rows also try echoing $query12 to check if its correct, also try chaning the and to AND Quote Link to comment https://forums.phpfreaks.com/topic/145197-how-do-i-check-2-fields/#findComment-762134 Share on other sites More sharing options...
richarro1234 Posted February 14, 2009 Author Share Posted February 14, 2009 it just shows up as "SELECT * FROM friends WHERE myid='1' AND friendsid='1' LIMIT 5 " print_r($query12=" SELECT * FROM friends WHERE myid='$urid' AND friendsid='$urid' LIMIT 5"); $result=mysql_query($query12) or die ('Error: '.mysql_error ()); $num=mysql_numrows($result); Quote Link to comment https://forums.phpfreaks.com/topic/145197-how-do-i-check-2-fields/#findComment-762138 Share on other sites More sharing options...
DeanWhitehouse Posted February 14, 2009 Share Posted February 14, 2009 Hmm, and still just printing "Error: " ? Quote Link to comment https://forums.phpfreaks.com/topic/145197-how-do-i-check-2-fields/#findComment-762140 Share on other sites More sharing options...
richarro1234 Posted February 14, 2009 Author Share Posted February 14, 2009 no, it doesnt show an error anymore it just shows up SELECT * FROM friends WHERE myid='1' AND friendsid='1' LIMIT 5 but when i remove the print_r() it doesnt show anything (and its onviously meant to show the firends). Quote Link to comment https://forums.phpfreaks.com/topic/145197-how-do-i-check-2-fields/#findComment-762147 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.