TottoBennington Posted April 9, 2012 Share Posted April 9, 2012 mysql_result() : supplied argument is not a valid result in ..... function previously_liked ($article_id) { $article_id = (int) $article_id; return (mysql_result(mysql_query("SELECT COUNT(`like_id`) FROM `likes` WHERE `like_id` = " .$_SESSION['user_id']. " AND `article_id` = $article_id"), 0) == 0 ) ? false : true; // this is the line with the error. } Quote Link to comment https://forums.phpfreaks.com/topic/260608-php-warning-mysql_result/ Share on other sites More sharing options...
Muddy_Funster Posted April 9, 2012 Share Posted April 9, 2012 that's just really lazy coding, see what this get's you back, after you change the bits in <> for the if at the end. function previously_liked ($article_id) { $article_id = (int) $article_id; $sql = "SELECT COUNT(`like_id`) FROM `likes` WHERE `like_id` = {$_SESSION['user_id']} AND `article_id` = $article_id"; $qry = mysql_query($sql) or die("could not perform the following query:<br>\n $sql<br>\n <br>\n The folowwing error was returned from the server:<br>\n".mysql_error()); $result = mysql_result($qry) if ($result == <whatever your trying to do>){ $result = <whatever you want it to be>; } else{ $result = <the other thing>; } return $result; } Quote Link to comment https://forums.phpfreaks.com/topic/260608-php-warning-mysql_result/#findComment-1335615 Share on other sites More sharing options...
NLT Posted April 9, 2012 Share Posted April 9, 2012 that's just really lazy coding, see what this get's you back, after you change the bits in <> for the if at the end. function previously_liked ($article_id) { $article_id = (int) $article_id; $sql = "SELECT COUNT(`like_id`) FROM `likes` WHERE `like_id` = {$_SESSION['user_id']} AND `article_id` = $article_id"; $qry = mysql_query($sql) or die("could not perform the following query:<br>\n $sql<br>\n <br>\n The folowwing error was returned from the server:<br>\n".mysql_error()); $result = mysql_result($qry) if ($result == <whatever your trying to do>){ $result = <whatever you want it to be>; } else{ $result = <the other thing>; } return $result; } Doesn't mysql_result need two arguments? Quote Link to comment https://forums.phpfreaks.com/topic/260608-php-warning-mysql_result/#findComment-1335616 Share on other sites More sharing options...
litebearer Posted April 9, 2012 Share Posted April 9, 2012 http://php.net/manual/en/function.mysql-result.php Quote Link to comment https://forums.phpfreaks.com/topic/260608-php-warning-mysql_result/#findComment-1335625 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.