Link to home
Start Free TrialLog in
Avatar of Robert Granlund
Robert GranlundFlag for United States of America

asked on

PHP PDO Error message

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.
ASKER CERTIFIED SOLUTION
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Robert Granlund

ASKER

Ah Geez man.  Thanks.  I guess I'm tired!
You're welcome.