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! Quote Link to comment 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. Quote Link to comment 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? Quote Link to comment 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 Quote Link to comment 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.