Solved

PHP PDO Error message

Posted on 2013-11-08
3
573 Views
Last Modified: 2013-11-08
I'm getting an error:
Notice: Trying to get property of non-object in... Line: 3
$asset = new ShowAssets();
$ass = $asset->Asset($_GET['id']);
echo '<form action="edit_asset.php?id='. $ass->asset_id .'" method="post">

Open in new window

here is the function:
function Asset($id = 0) {
			$pdo = new PDO("mysql:host=localhost);
			$pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ);
			$sqla = "SELET *
					FROM assets
					WHERE asset_id = :id";
			$asset = $pdo->prepare($sqla);
			$asset->bindParam(':id', $id, PDO::PARAM_STR);
			
			try	{
				$asset->execute(array('id' => $id));	
				$results = $asset->fetch();
				return $results;
			}
			catch(PDOException $a) {
   				echo 'ERROR: ' . $a->getMessage();
			}
		}

Open in new window

I have no clue what the issue is.
0
Comment
Question by:rgranlund
  • 2
3 Comments
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 500 total points
ID: 39634930
Maybe you're not returning anything.  Line 4 of your function, SELET should be SELECT.
0
 
LVL 7

Author Closing Comment

by:rgranlund
ID: 39635004
Ah Geez man.  Thanks.  I guess I'm tired!
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 39635018
You're welcome.
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question