Solved

PHP PDO Error message

Posted on 2013-11-08
3
569 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

930 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now