arguement is not valid.

Ask about a PHP problem here.
Post Reply
prothseda
Posts: 3
Joined: Sun Jun 24, 2012 4:13 am

arguement is not valid.

Post 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
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: arguement is not valid.

Post 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.
Image
prothseda
Posts: 3
Joined: Sun Jun 24, 2012 4:13 am

Re: arguement is not valid.

Post 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.
User avatar
Temor
Posts: 1186
Joined: Thu May 05, 2011 8:04 pm

Re: arguement is not valid.

Post by Temor »

 if (isset($_Get['pid']) === false 
It's supposed to be $_GET not $_Get
prothseda
Posts: 3
Joined: Sun Jun 24, 2012 4:13 am

Re: arguement is not valid.

Post by prothseda »

TYVM - I'm far too inexperienced to have noticed the case sensitiveness :P
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: arguement is not valid.

Post by jacek »

prothseda wrote:TYVM - I'm far too inexperienced to have noticed the case sensitiveness :P
You will from now on though :D LEARNING ! 8-)
Image
Post Reply