MrXortex Posted May 17, 2012 Share Posted May 17, 2012 G'day. I got this error when I try to register a user. The function will basically check if the user already exist in the database or not. Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /hermes/web05/blubbz/functions/user.func.php on line 21 CODE: <?php function logged_in() { } function login_check($email, $password) { } function user_data() { } function user_register ($email, $name, $password) { } function user_exists ($email) { $email = mysql_real_escape_string($email); $query = mysql_query("SELECT COUNT('user_id') FROM 'users' WHERE 'email' = '$email'"); return (mysql_result($query, 0) == 1) ? true : false; } ?> Line 21 is: return (mysql_result($query, 0) == 1) ? true : false; Quote Link to comment https://forums.phpfreaks.com/topic/262684-warning-mysql_result-supplied-argument-is-not-a-valid-mysql-result-resource/ Share on other sites More sharing options...
Barand Posted May 17, 2012 Share Posted May 17, 2012 After the query, echo mysql_error() My guess is it's the quotes around your table name. Quote Link to comment https://forums.phpfreaks.com/topic/262684-warning-mysql_result-supplied-argument-is-not-a-valid-mysql-result-resource/#findComment-1346381 Share on other sites More sharing options...
MrXortex Posted May 17, 2012 Author Share Posted May 17, 2012 I tried changing the quotes, but I got the same error. Any other help please? Quote Link to comment https://forums.phpfreaks.com/topic/262684-warning-mysql_result-supplied-argument-is-not-a-valid-mysql-result-resource/#findComment-1346384 Share on other sites More sharing options...
Barand Posted May 17, 2012 Share Posted May 17, 2012 What did mysql_error() output? Quote Link to comment https://forums.phpfreaks.com/topic/262684-warning-mysql_result-supplied-argument-is-not-a-valid-mysql-result-resource/#findComment-1346385 Share on other sites More sharing options...
MrXortex Posted May 17, 2012 Author Share Posted May 17, 2012 Where do I put that mysql_output? Give the whole code please? Quote Link to comment https://forums.phpfreaks.com/topic/262684-warning-mysql_result-supplied-argument-is-not-a-valid-mysql-result-resource/#findComment-1346388 Share on other sites More sharing options...
Barand Posted May 17, 2012 Share Posted May 17, 2012 After the query, echo mysql_error() Quote Link to comment https://forums.phpfreaks.com/topic/262684-warning-mysql_result-supplied-argument-is-not-a-valid-mysql-result-resource/#findComment-1346389 Share on other sites More sharing options...
mrMarcus Posted May 17, 2012 Share Posted May 17, 2012 I tried changing the quotes, but I got the same error. Any other help please? To what? $query = mysql_query("SELECT COUNT('user_id') FROM 'users' WHERE 'email' = '$email'"); Should be: $query = mysql_query("SELECT COUNT(`user_id`) FROM `users` WHERE `email` = '$email'"); Quote Link to comment https://forums.phpfreaks.com/topic/262684-warning-mysql_result-supplied-argument-is-not-a-valid-mysql-result-resource/#findComment-1346391 Share on other sites More sharing options...
MrXortex Posted May 17, 2012 Author Share Posted May 17, 2012 Okay, I got this error now Parse error: syntax error, unexpected T_RETURN, expecting ',' or ';' in user.func.php on line 22. Line 22: return (mysql_result($query, 0) == 1) ? true : false; Quote Link to comment https://forums.phpfreaks.com/topic/262684-warning-mysql_result-supplied-argument-is-not-a-valid-mysql-result-resource/#findComment-1346392 Share on other sites More sharing options...
mrMarcus Posted May 17, 2012 Share Posted May 17, 2012 Post your updated version of that function please. Quote Link to comment https://forums.phpfreaks.com/topic/262684-warning-mysql_result-supplied-argument-is-not-a-valid-mysql-result-resource/#findComment-1346393 Share on other sites More sharing options...
MrXortex Posted May 17, 2012 Author Share Posted May 17, 2012 Thanks a lot guys, its working now. All I had to do is replace those quotes, I misplaced them. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/262684-warning-mysql_result-supplied-argument-is-not-a-valid-mysql-result-resource/#findComment-1346394 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.