Robert Granlund
asked on
PHP PDO Error message
I'm getting an error:
Notice: Trying to get property of non-object in... Line: 3
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">
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();
}
}
I have no clue what the issue is.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You're welcome.
ASKER