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? 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. 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. 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 Quote Do NOT use mysqli_error(), as you cannot mix mysql and mysqli. Thanks, I didn't notice that. 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. 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 Quote $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 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. 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 Quote You have a spelling error in your query. i know this can you show me where is the error? 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. 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 ? 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(). Link to comment https://forums.phpfreaks.com/topic/251474-warning-mysql_result/#findComment-1289817 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.