Jump to content

Notice: Trying to get property of non-object in


cerberus478

Recommended Posts

Hi

 

I'm getting this error

 

 

Notice: Trying to get property of non-object in line 17

 

on that line is

$this->name = $result->name;

this is the entire line

function setFromDatabase(){
		global $_FRAMES_TABLE;
		$query = mysql_query("SELECT * FROM $_FRAMES_TABLE WHERE id='$this->id'");
		$result = mysql_fetch_object($query);
		$this->name = $result->name;
		$this->content = $result->content;
		$this->image = $result->image;

	}

I'm not sure why I'm getting this error or how I can go about fixing it

your query didn't match any rows and $result is a false value instead of an object from the mysql_fetch_object() statement. the WHERE clause in the query is false, either because there's no row where id = '$this->id' or $this->id may be empty.

 

where did you get this code? it doesn't have any error checking logic (the errors in some of your previous threads), nor is it testing if the query matched any rows before trying to use the data from the query (the error in this thread)?

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.