TottoBennington Posted March 25, 2012 Share Posted March 25, 2012 Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /home/tottoswd/public_html/iuw/func/user.func.php on line 4 <?php function user_exists($email) { $email = mysql_real_escape_string($email); $query = mysql_query("SELECT COUNT(´user_id´) FROM ´users_vu´ WHERE ´email´ = '$email'"); return (mysql_result($query, 0) == 1) ? true : false; (THIS IS THE LINE WITH THE ERROR) ?> Quote Link to comment https://forums.phpfreaks.com/topic/259687-mysql_result-error/ Share on other sites More sharing options...
dragon_sa Posted March 25, 2012 Share Posted March 25, 2012 I believe this is an issue with the statement try changing it to this $query = mysql_query("SELECT COUNT(user_id) FROM users_vu WHERE email = '$email'"); Quote Link to comment https://forums.phpfreaks.com/topic/259687-mysql_result-error/#findComment-1330952 Share on other sites More sharing options...
cpd Posted March 25, 2012 Share Posted March 25, 2012 Whether you use the slanted apostrophe or not shouldn't matter. The correct syntax and good practice is to use the apostrophe; but as I said, is not required. I believe the error is due to your "COUNT" function. Try putting am as statement and accessing the alias: "COUNT(*) AS Total". $query = mysql_query("SELECT COUNT(´user_id´) AS `User` FROM ´users_vu´ WHERE ´email´ = '$email'"); return (mysql_result($query, 0, 'User') == 1) ? true : false; (THIS IS THE LINE WITH THE ERROR) Quote Link to comment https://forums.phpfreaks.com/topic/259687-mysql_result-error/#findComment-1331043 Share on other sites More sharing options...
scootstah Posted March 25, 2012 Share Posted March 25, 2012 The problem is that you are using some other kind of apostrophe and not a back-tick. This is correct: $query = mysql_query("SELECT COUNT(`user_id`) FROM `users_vu` WHERE `email` = '$email'"); Quote Link to comment https://forums.phpfreaks.com/topic/259687-mysql_result-error/#findComment-1331045 Share on other sites More sharing options...
cpd Posted March 25, 2012 Share Posted March 25, 2012 Oh dear, my failure to pay attention to detail :|. Quote Link to comment https://forums.phpfreaks.com/topic/259687-mysql_result-error/#findComment-1331049 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.