Jump to content

Odd php issue with mysql strings.


whelpton

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/233273-odd-php-issue-with-mysql-strings/
Share on other sites

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.

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.