HenryCan Posted February 2, 2013 Share Posted February 2, 2013 How can I tell if a given installation has PDO installed? I'm using a hosting service and they have PHP 5.3.19 but I suspect they don't have PDO. I'm just not sure how to tell if it is there. I'm new to php but not to database work. I was trying to perfect some mysql_query code when I stumbled on the existence of PDO, which is apparently the preferred method of doing database access these days. I had a look at the PDO tutorial and found it very familiar. I reworked one of my programs to use PDO but now that I'm executing it for the first time, I'm getting an error message that makes me think PDO isn't installed because it doesn't comprehend the -> operator. Here's the error message: Parse error: syntax error, unexpected '>' in /home/foo/public_html/topic_proposal_theme.php on line 106 And here's the statement that is executing: $stmt->execute(array(':date_proposed' ==> $date_proposed, ':proposer' ==> $proposer, ':title' ==> $title, ':discuss' ==> $discuss, ':prepare' ==> $prepare, ':comments' ==> $comments)); The funny thing is that this isn't the very first PDO statement or use of the -> operator in the progam. There are other statements in an include that gets the database connection; that include is situated several lines before the code that is failing. If PDO really wasn't there, I'd expect to see this error either the first time it encountered the -> operator or every time. So maybe I'm completely wrong in assuming PDO isn't there. Maybe there is something else wrong. But I've imitated the PDO tutorial examples pretty carefully so I'm not seeing my error if I've made a simple typo. Quote Link to comment https://forums.phpfreaks.com/topic/273935-detecting-pdo/ Share on other sites More sharing options...
HenryCan Posted February 2, 2013 Author Share Posted February 2, 2013 I just realized I had a way to get some information about PDO in my installation of PHP: info.php. I had a look at its list of values and found a few that mentioned PDO: PDO PDO support enabled PDO drivers sqlite, mysql, sqlite2 pdo_mysql PDO Driver for MySQL enabled Client API version 5.1.65 Directive Local Value Master Value pdo_mysql.default_socket /var/lib/mysql/mysql.sock /var/lib/mysql/mysql.sock pdo_sqlite PDO Driver for SQLite 3.x enabled SQLite Library 3.7.7.1 This confirms that I have PDO, right? Do I need to have any standard statements in my program in order to access PDO? For instance, in Java I'd import the Java classes that I was using in my program. Is there a PHP equivalent that I need to do if I'm using PDO in a given program? Quote Link to comment https://forums.phpfreaks.com/topic/273935-detecting-pdo/#findComment-1409635 Share on other sites More sharing options...
requinix Posted February 2, 2013 Share Posted February 2, 2013 Parse errors have nothing to do with the extensions that are loaded. It means there is a fundamental flaw in the code that was typed. It does not conform to the syntax for the PHP language. In this case there's ==>s for the array arrows. That's wrong. There is only one equals sign. $stmt->execute(array(':date_proposed' => $date_proposed, ':proposer' => $proposer, ':title' => $title, ':discuss' => $discuss, ':prepare' => $prepare, ':comments' => $comments)); Quote Link to comment https://forums.phpfreaks.com/topic/273935-detecting-pdo/#findComment-1409638 Share on other sites More sharing options...
HenryCan Posted February 2, 2013 Author Share Posted February 2, 2013 Thank you VERY much requinix! I completely misread the example I found and thought I was seeing ==> where it was only =>. I'm past that problem and on to a new one ;-) Quote Link to comment https://forums.phpfreaks.com/topic/273935-detecting-pdo/#findComment-1409745 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.