whelpton Posted April 10, 2011 Share Posted April 10, 2011 Hey guys, I have used this code before on a linux server and know that it works, however after porting my site over to a windows server running apache, php and mysql; the following code seems to make one of my scripts crash. $queryfam1 = "SELECT * FROM wp_users WHERE user_login='$username'"; $resultfam1 = mysql_query($queryfam1) or die(mysql_error()); $row21 = mysql_fetch_array($resultfam1) or die(mysql_error()); I have no idea of a result as there is no error reported, it simply dies and does not tell me what is happening with it. Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/233273-odd-php-issue-with-mysql-strings/ Share on other sites More sharing options...
Jnerocorp Posted April 10, 2011 Share Posted April 10, 2011 try: $queryfam1 = "SELECT * FROM wp_users WHERE user_login='$username'"; $resultfam1 = mysql_query($queryfam1) or die(mysql_error()); while($row21 = mysql_fetch_array($resultfam1)) { echo "$row21['field_name_here']; } Quote Link to comment https://forums.phpfreaks.com/topic/233273-odd-php-issue-with-mysql-strings/#findComment-1199676 Share on other sites More sharing options...
whelpton Posted April 10, 2011 Author Share Posted April 10, 2011 @Jnerocorp, still no luck. Script dies after the command. Quote Link to comment https://forums.phpfreaks.com/topic/233273-odd-php-issue-with-mysql-strings/#findComment-1199678 Share on other sites More sharing options...
PFMaBiSmAd Posted April 10, 2011 Share Posted April 10, 2011 Putting or die(mysql_error()) on the end of a mysql_fetch_xxxxx() statement makes no sense, because mysql_fetch_xxxxx() statements don't set mysql_error() and the original code would die() with nothing being output to the browser when the query matches zero rows. Quote Link to comment https://forums.phpfreaks.com/topic/233273-odd-php-issue-with-mysql-strings/#findComment-1199681 Share on other sites More sharing options...
PFMaBiSmAd Posted April 10, 2011 Share Posted April 10, 2011 Your query is probably matching zero rows. Where is $username getting set at AND you should echo $queryfam1 so you can see exactly what the query is AND you should use mysql_num_rows to find out how many rows the query matched. Quote Link to comment https://forums.phpfreaks.com/topic/233273-odd-php-issue-with-mysql-strings/#findComment-1199684 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.