Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

easiest test other than php.ini to test to see if pdo is working

Posted on 2011-09-18
10
Medium Priority
?
441 Views
Last Modified: 2013-12-13
easiest test other than php.ini to test to see if pdo is working
0
Comment
Question by:rgb192
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
10 Comments
 
LVL 84

Accepted Solution

by:
Dave Baldwin earned 2000 total points
ID: 36558030
I normally write a small test page to get 10 rows or so like the sample below.  Change the details to your data and check your connections and info.  Once that is working then you can do more complicated things with some confidence.
<?php 
// DB configuration
$dbhost = "10.202.46.41";
$dbuser = "eecontact";
$dbpass = "easy4U";
$dbname = "nads";
$dbtable = "customercontact";
$dbdsn = "mysql:dbname=$dbname;host=$dbhost";

$dbh = new PDO($dbdsn, $dbuser, $dbpass);

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<title>PDO dbCheck</title>
</head>
<body>
<?php 
echo "Host: $dbhost <br>";
?>
<table border="0" cellpadding="1" cellspacing="1" summary="local people" width="900px" bgcolor="#ffffff">
<caption><font style="font-weight: bold; font-size: 18pt; line-height: 24pt;">PDO::MySQL check</font></caption>
<tbody>
<tr bgcolor="#ffffff">
<th>id</th><th>name</th><th>phone</th><th>email</th><th>zip</th></tr>
<?php 
$wlsql = "SELECT * FROM $dbtable LIMIT 10";
$sth = $dbh->prepare($wlsql);
$sth->execute();

while ($row = $sth->fetch(PDO::FETCH_BOTH)) {
echo '<tr>';
echo '<td>'.$row['firstName'].'</td>';
echo '<td>'.$row['lastName'].'</td>';
echo '<td>'.$row['city'].'</td>';
echo '<td>'.$row['email'].'</td>';
echo '<td>'.$row['zip'].'</td>';
echo '</td></tr>';
}
?>
</tbody> 
</table>

</body>
</html>

Open in new window

0
 

Author Comment

by:rgb192
ID: 36558074
Fatal error: Class 'PDO' not found

so I think this means that pdo is not enabled on wamp

and I can not find pdo in php.ini even though I uncommented all the pdo lines
0
 
LVL 13

Expert Comment

by:dsmile
ID: 36558121
Create php file with this content <?php phpinfo();?>

See if you're using the right php.ini
0
Flash Sale! Good things come in big bundles

Save over 50% on our fully managed dedicated server bundle for Labor Day. Plus FREE Guardian Backups, FREE Advanced DDoS Protection and FREE Plesk Onyx Web Pro Edition.

 

Author Comment

by:rgb192
ID: 36558161
i am using correct php.ini
dave
code works using php ide (using a different php.ini)
0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 36558197
I just checked and it works fine in WAMP on my computer.  I enabled PDO using the tray icon for WAMP.  It's the only version of PHP I have on that computer.
0
 

Author Comment

by:rgb192
ID: 36563915
I followed your advice and enabled all the pdo using extensions on tray icon for wamp

I had to add these one at a time and after I added each, wamp restarted.

I still get same error.

0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 36564006
I assume that they show up in 'phpinfo()' on WAMP.  I don't know what to tell you at this point since the code is known to work on WAMP and on IIS on another computer.   Any chance the two versions of PHP are interfering with each other?
0
 

Author Comment

by:rgb192
ID: 36937586
one is for ide
other is for wamp

so I dont think there is interferance
0
 

Author Closing Comment

by:rgb192
ID: 37128945
this code sample did the trick
0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 37129220
Good, glad to help.
0

Featured Post

WordPress Tutorial 3: Plugins, Themes, and Widgets

The three most common changes you will make to your website involve the look (themes), the functionality (plugins), and modular elements (widgets).

In this article we will briefly define each again, and give you directions on how to install them.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

730 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