Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

what includes do i need for PDO?

Status
Not open for further replies.

aa__live

Programmer
Mar 29, 2017
28
0
0
GB
I'm not sure if PDO is built in PHP so are there any includes required top of a page to run a query?
Code:
$stmt = $pdo->query("SELECT id,importsNumber FROM table");

This give me error -
Undefined variable: pdo​
 
You need to enable it in php.ini

"Trying is the first step to failure..." - Homer
 
It is and this is working for clarification

Code:
$pdo =  new Pdo('mysql:dbname=badbidder1;host=localhost', $username, $password);

//get the import number that is left and id
$stmt = $pdo->query("SELECT id,importsNumber FROM `bad_users` where username ='carquest'");

while ($row = $stmt->fetch())
{
	$youruserid = $row['id'];
	$import_num = $row['importsNumber'];	
}
 
So what is different about code 'A' (not working) to code 'B' (working).


'We' (as in the royal 'we') cannot tell, because you have only provided one line of code for 'A'.

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.

Never mind this jesus character, stars had to die for me to live.
 
I didnt do this before hand!!
Code:
$pdo =  new Pdo('mysql:dbname=badbidder1;host=localhost', $username, $password);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top