Solved

PHP PDO Error message

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

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 82

Expert Comment

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

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article discusses four methods for overlaying images in a container on a web page
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
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 create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

705 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

14 Experts available now in Live!

Get 1:1 Help Now