Jump to content

[SOLVED] Fatal Error and It's Killing Me


phpretard

Recommended Posts

Does anyone know why I would get this? Fatal error: Can't use function return value in write context

 

$SEARCH="AB";

if (!ereg('[^A-Z]', $SEARCH) && (strlen($SEARCH) = 2))){

$searchResult = mysql_query("
SELECT * FROM members WHERE 
LicState LIKE '%$SEARCH%' OR 
LicState2 '%$SEARCH%' OR 
LicState3 LIKE '%$SEARCH%' OR 
LicState4 LIKE '%$SEARCH%' ");}

if (!searchResult){die(mysql_error());}

$num_rows= mysql_num_rows($searchResult);

echo $num_rows." FOUND";

 

I am looking for: "1 FOUND" ...and I get: Fatal error: Can't use function return value in write context

 

Thank again!

 

Link to comment
https://forums.phpfreaks.com/topic/128938-solved-fatal-error-and-its-killing-me/
Share on other sites

I'm going to assume it's on this line:

 

if (!ereg('[^A-Z]', $SEARCH) && (strlen($SEARCH) = 2))){

 

You are using the = operator, which is trying to write to the return value of strlen(). Make it == and the error should go away.

I took your advise on both post (THANK YOU!)

 

I now get: mysql_num_rows(): supplied argument is not a valid MySQL result resource...on line 17

 

if (!ereg('[^A-Z]', $SEARCH) && (strlen($SEARCH) == 2)){

$searchResult = mysql_query("
SELECT * FROM members WHERE 
LicState LIKE '%$SEARCH%' OR 
LicState2 '%$SEARCH%' OR 
LicState3 LIKE '%$SEARCH%' OR 
LicState4 LIKE '%$SEARCH%' ");}

if (!searchResult){die(mysql_error());}

$num_rows= mysql_num_rows($searchResult); << -------- LINE 17

echo $num_rows." FOUND";

}

 

Any ideas on this?

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.