phpretard Posted October 18, 2008 Share Posted October 18, 2008 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 More sharing options...
JasonLewis Posted October 18, 2008 Share Posted October 18, 2008 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. Link to comment https://forums.phpfreaks.com/topic/128938-solved-fatal-error-and-its-killing-me/#findComment-668485 Share on other sites More sharing options...
phpretard Posted October 18, 2008 Author Share Posted October 18, 2008 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? Link to comment https://forums.phpfreaks.com/topic/128938-solved-fatal-error-and-its-killing-me/#findComment-668488 Share on other sites More sharing options...
kenrbnsn Posted October 18, 2008 Share Posted October 18, 2008 You missed a "$" in this line: <?php if (!searchResult){die(mysql_error());} ?> it should be <?php if (!$searchResult){die(mysql_error());} ?> Ken Link to comment https://forums.phpfreaks.com/topic/128938-solved-fatal-error-and-its-killing-me/#findComment-668490 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.