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

Link to comment
Share on other sites

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)?

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.