ctcp Posted November 20, 2011 Share Posted November 20, 2011 <?php $liked = ("SELETCT SUM(user_id) as totaluser_id FROM liked WHERE `user_id`='26762'"); $liked_results = mysql_query($liked); $sum_liked = mysql_result($liked, 0); // <--- Error echo $sum_liked; ?> i got this error Warning: mysql_result(): supplied argument is not a valid MySQL result resource in can sombady help? Quote Link to comment https://forums.phpfreaks.com/topic/251474-warning-mysql_result/ Share on other sites More sharing options...
floridaflatlander Posted November 20, 2011 Share Posted November 20, 2011 Did you use or die("Error: ".mysqli_error($dbc)) ? If I had to """guess""" one of you variables is bad. Quote Link to comment https://forums.phpfreaks.com/topic/251474-warning-mysql_result/#findComment-1289700 Share on other sites More sharing options...
jcbones Posted November 20, 2011 Share Posted November 20, 2011 $liked_results = mysql_query($liked) or trigger_error(mysql_error()); Do NOT use mysqli_error(), as you cannot mix mysql and mysqli. Quote Link to comment https://forums.phpfreaks.com/topic/251474-warning-mysql_result/#findComment-1289718 Share on other sites More sharing options...
floridaflatlander Posted November 20, 2011 Share Posted November 20, 2011 Do NOT use mysqli_error(), as you cannot mix mysql and mysqli. Thanks, I didn't notice that. Quote Link to comment https://forums.phpfreaks.com/topic/251474-warning-mysql_result/#findComment-1289723 Share on other sites More sharing options...
PFMaBiSmAd Posted November 20, 2011 Share Posted November 20, 2011 The variable you put into the mysql_result() statement is not the variable you assigned the result resource from the mysql_query() statement to. Quote Link to comment https://forums.phpfreaks.com/topic/251474-warning-mysql_result/#findComment-1289724 Share on other sites More sharing options...
ctcp Posted November 20, 2011 Author Share Posted November 20, 2011 $liked_results = mysql_query($liked) or trigger_error(mysql_error()); Do NOT use mysqli_error(), as you cannot mix mysql and mysqli. Notice: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELETCT SUM(user_id) as totaluser_id FROM liked WHERE user_id = 26762' at line 1 in Quote Link to comment https://forums.phpfreaks.com/topic/251474-warning-mysql_result/#findComment-1289735 Share on other sites More sharing options...
PFMaBiSmAd Posted November 20, 2011 Share Posted November 20, 2011 You have a spelling error in your query. Quote Link to comment https://forums.phpfreaks.com/topic/251474-warning-mysql_result/#findComment-1289764 Share on other sites More sharing options...
ctcp Posted November 20, 2011 Author Share Posted November 20, 2011 You have a spelling error in your query. i know this can you show me where is the error? Quote Link to comment https://forums.phpfreaks.com/topic/251474-warning-mysql_result/#findComment-1289804 Share on other sites More sharing options...
Pikachu2000 Posted November 20, 2011 Share Posted November 20, 2011 Read the error message. It's very apparent which word is misspelled. Quote Link to comment https://forums.phpfreaks.com/topic/251474-warning-mysql_result/#findComment-1289805 Share on other sites More sharing options...
ctcp Posted November 20, 2011 Author Share Posted November 20, 2011 <?php $liked = ("SELECT SUM(user_id) as totaluser_id FROM liked WHERE `user_id`='26762'"); $liked_results = mysql_query($liked); $sum_liked = mysql_result($liked, 0); // <-- line 15 echo $sum_liked; $liked_results = mysql_query($liked) or trigger_error(mysql_error()); ?> mate i got this error now Warning: mysql_result(): supplied argument is not a valid MySQL result resource in mpla mpla on line 15 what is wrong now ? Quote Link to comment https://forums.phpfreaks.com/topic/251474-warning-mysql_result/#findComment-1289814 Share on other sites More sharing options...
Pikachu2000 Posted November 20, 2011 Share Posted November 20, 2011 You're passing the variable that holds the query string, rather than the result resource to mysql_result(). Quote Link to comment https://forums.phpfreaks.com/topic/251474-warning-mysql_result/#findComment-1289817 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.