[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 615
  • Last Modified:

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.
0
rgranlund
Asked:
rgranlund
  • 2
1 Solution
 
Dave BaldwinFixer of ProblemsCommented:
Maybe you're not returning anything.  Line 4 of your function, SELET should be SELECT.
0
 
rgranlundAuthor Commented:
Ah Geez man.  Thanks.  I guess I'm tired!
0
 
Dave BaldwinFixer of ProblemsCommented:
You're welcome.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now