Jump to content

PHP Warning, Mysql_result() ...


TottoBennington

Recommended Posts

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.
}

Link to comment
https://forums.phpfreaks.com/topic/260608-php-warning-mysql_result/
Share on other sites

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;
}

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.