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

Link to comment
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;
}

 

Doesn't mysql_result need two arguments?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.