Call to undefined function mysql_pconnect()

Wow. This took ages.
A customer of mine has developed a PHP application on his windows machine (yeah yeah I know). I tried installing it on my Linux laptop – and all I got was a white page.
Well, loving the challenge, I started putting in debu prints in all the PHP files. Turns out the customer uses CodeIgniter, so I started with core/CodeIgniter.php, moved to core/Loader.php, core/db/DB.php and ended up with the mysql_driver.php.
Turns out I was crashing on this line:

return @mysql_pconnect($this->hostname, $this->username, $this->password);

The error message (after removing the @ of course) was
Call to undefined function mysql_pconnect()
So lame. I forgot to run sudo apt-get install php5-mysql. 2 hours of my life wasted 😦

3 thoughts on “Call to undefined function mysql_pconnect()

  1. Its bad that code igniter do not provide the error in its log (may be because of that @ it was not able to catch). So one way was to echo and exit line by line. However, there is an another way, which is to use this simple function given at the end of this post.

    Using some techqnique like is important because I was able to reach to your blog only when I googled the error (Call to undefined function mysql_pconnect()) but finding the error in first place was the challenge.

    I am wondering why did not codeigniter put this in first place. Now, its a good thought to raise an issue on codeigniter git hub and do 2 things:
    1. put all error catcher function () something like this (more proper with proper format and exception,etc)
    2. remove the @ whereever possible.

    Thanks 🙂


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s