Page 1 of 1
arguement is not valid.
Posted: Sun Jun 24, 2012 4:16 am
by prothseda
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /www/clanteam.com/z/a/c/zachary-mcguire/htdocs/core/includes/posts.inc.php on line 42
While (($row = mysql_fetch_assoc($posts)) !== false){
$rows[] = array(
'id' => $row['id'],
'title' => $row['title'],
'preview' => $row['preview'],
'user' => $row['user'],
'data' => $row['date'],
'total_comments' => ($row['total_comments'] === null) ? 0 : $row['total_comments'],
'last_comment' => ($row['last_comments'] === null) ? 'never' : $row['last_comment']
);
}
Would someone be able to tell me why I am receiving this error. The code is supplied above. Thank you.
EDIT: That is the code that is on line 42 of that php file.
EDIT TWO: http://pastesite.com/38590
Re: arguement is not valid.
Posted: Sun Jun 24, 2012 1:32 pm
by jacek
That usually means your query is failing, when that happens mysql_query() will return false which is not a valid result.
You can find out why it failed by adding
echo mysql_error();
after the mysql_query() line.
Re: arguement is not valid.
Posted: Mon Jun 25, 2012 4:50 am
by prothseda
I have fixed that issue, I was missing a ` off `post_id` in the previous line.
I have another issue though.
I'm on the last of your tutorials (EP6) and the page always returns the 'Invalid post ID' message.
<?php
if (isset($_Get['pid']) === false || valid_pid($_GET['pid']) === false){
echo 'Invalid post ID.';
}else{
$post = get_post($_GET['pid']);
?>
<?php
include('../init.inc.php');
if (isset($_GET['pid'], $_POST['user'], $_POST['body'])){
if (add_comment($_GET['pid'], $_POST['user'], $_POST['body'])){
header("Location: blog_read.php?pid={$_GET['pid']}");
}else{
header('Location: blog_list.php');
}
die();
}
?>
They're the two PHP syntaxes that were in the video and I can't see any difference in them...
I have blog posts and comments in my SQL database and they both show up on blog_list.php but apparently the post ID is invalid on the blog_read page.
Re: arguement is not valid.
Posted: Mon Jun 25, 2012 6:02 am
by Temor
if (isset($_Get['pid']) === false
It's supposed to be $_GET not $_Get
Re: arguement is not valid.
Posted: Mon Jun 25, 2012 7:55 am
by prothseda
TYVM - I'm far too inexperienced to have noticed the case sensitiveness
Re: arguement is not valid.
Posted: Tue Jun 26, 2012 2:07 pm
by jacek
prothseda wrote:TYVM - I'm far too inexperienced to have noticed the case sensitiveness
You will from now on though
LEARNING !