Error when trying to use PDO object

Posted by Nate on Stack Overflow See other posts from Stack Overflow or by Nate
Published on 2012-07-05T15:09:22Z Indexed on 2012/07/05 15:15 UTC
Read the original article Hit count: 282

Filed under:
|
|

EDIT: I'm going to put my code in here due to comments below. So sit tight for a few minutes ;-) Thanks!

I'm an inexperienced php programmer and only found out about PDO a few days ago. I'm now trying to port my website code over to using PDO, but I am getting an error when I try to use the PDO object that I create.

I'm using a CMS on my website, and it makes building page output kind of complicated, but I've tried to draw the structure of what is being called below:

index.php
-class myClass defined
--method myFunction defined (it gets called on pageload & returns the page output)
---include file1.php
----require_once('mysql_connect.php') (creates pdo object)
----*I can use the pdo object here successfully*
----require_once('file2.php')
-----require_once('mysql_connect.php')
-----function myFunction2 defined
------*trying to use the pdo object here results in the error*

The error I'm getting is:

Fatal error: Call to a member function prepare() on a non-object in /home/rgcpanel/public_html/account/account_functions.php on line 147

Any idea what's going on?

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql