php cannot connect to mysql

Asked by Stephen Mansfield on 2011-01-07

I just installed Ubuntu 10.10 LTS. I installed the LAMP package. For some reason php cannot connect to mysql. I have written a very simple php program to isolate the problem. My php program fails when I execute the ADONewConnection('mysql') command.

                    include('adodb/adodb.inc.php');
                    include('adodb/adodb-exceptions.inc.php');

 $host = 'localhost';
 $user = 'smansfie';
 $passwd = 'xxxxx_xxxx';
 $database = 'acregistration';

 $DB = ADONewConnection('mysql');
                    $DB->Connect($host, $user, $passwd, $database);

I did a 'ps aux | grep mysql' and got,

mysql 727 1.0 2.3 188180 24000? Ssl 10:50 0:00 /usr/sbin/mysqld

Plus I can log into mysql with no problems so I am pretty sure mysql is at least running. I did see an earlier posting with the same probelm. The fix was to include a statement in the file /etc/mysql/my.cnf 'skip-grant-tables'. However, this did not fix my problem. I did review my php installed packages and I believe I have the correct ones. The command dpkg -1 | grep php5 displays,

ii libapache2-mod-php5
ii php5-adodb
ii php5-cli
ii php5-common
ii php5-mysql

Anyone seen this problem?. Any ideas or suggestions? Debug strategies welcome.

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu php5 Edit question
Assignee:
No assignee Edit question
Solved by:
Hilario J. Montoliu (hjmf)
Solved:
2011-01-07
Last query:
2011-01-07
Last reply:
2011-01-07

Hi Stephen Mansfield,

You might get more info in the apache2 logs (/var/log/apache2/)

HTH

Ok I took HTH's advice and checked /var/log/apache2/error.log...

Several errors were posted but it looks like it cannot find include('adodb/adodb.inc.php') and include('adodb/adodb-exceptions.inc.php'). Of course without these files the NewADOConnection() was flagged as a 'Call to undefined function'. Specifically the error message said "PHP Warning: Failed opening 'adodb/adodb-exception.inc.php' for inclusion (include_path=' .:/usr/share/php:/usr/share/pear'). It this error message telling me to include the /usr/share/php:/usr/share/pear in my PATH statement? Any other thoughts?

Stephen Mansfield

Need some help...I included /usr/share/php5:/usr/share/pear in my $PATH command but did not fix the problem. I have pasted the error message below. Does anyone know where adodb/adodb.inc.php is located?

[Fri Jan 07 13:04:43 2011] [notice] Apache/2.2.16 (Ubuntu) PHP/5.3.3-1ubuntu9.1 with Suhosin-Patch configured -- resuming normal operations
[Fri Jan 07 13:04:57 2011] [error] [client 131.91.19.188] PHP Warning: include(adodb/adodb.inc.php): failed to open stream: No such file or directory in /var/www/skylease/getacCity.php on line 3, referer: http://lampserver01.vitessews.net/skylease/lease.html
[Fri Jan 07 13:04:57 2011] [error] [client 131.91.19.188] PHP Warning: include(): Failed opening 'adodb/adodb.inc.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/skylease/getacCity.php on line 3, referer: http://lampserver01.vitessews.net/skylease/lease.html
[Fri Jan 07 13:04:57 2011] [error] [client 131.91.19.188] PHP Warning: include(adodb/adodb-exceptions.inc.php): failed to open stream: No such file or directory in /var/www/skylease/getacCity.php on line 4, referer: http://lampserver01.vitessews.net/skylease/lease.html
[Fri Jan 07 13:04:57 2011] [error] [client 131.91.19.188] PHP Warning: include(): Failed opening 'adodb/adodb-exceptions.inc.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/skylease/getacCity.php on line 4, referer: http://lampserver01.vitessews.net/skylease/lease.html
[Fri Jan 07 13:04:57 2011] [error] [client 131.91.19.188] PHP Fatal error: Call to undefined function NewADOConnection() in /var/www/skylease/getacCity.php on line 12, referer: http://lampserver01.vitessews.net/skylease/lease.html
[Fri Jan 07 13:07:34 2011] [error] [client 109.230.251.8] File does not exist: /var/www/error

Need some help...I included /usr/share/php5:/usr/share/pear in my $PATH command but did not fix the problem. I have pasted the error message below. Does anyone know where adodb/adodb.inc.php is located?

[Fri Jan 07 13:04:43 2011] [notice] Apache/2.2.16 (Ubuntu) PHP/5.3.3-1ubuntu9.1 with Suhosin-Patch configured -- resuming normal operations
[Fri Jan 07 13:04:57 2011] [error] [client 131.91.19.188] PHP Warning: include(adodb/adodb.inc.php): failed to open stream: No such file or directory in /var/www/skylease/getacCity.php on line 3, referer: http://lampserver01.vitessews.net/skylease/lease.html
[Fri Jan 07 13:04:57 2011] [error] [client 131.91.19.188] PHP Warning: include(): Failed opening 'adodb/adodb.inc.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/skylease/getacCity.php on line 3, referer: http://lampserver01.vitessews.net/skylease/lease.html
[Fri Jan 07 13:04:57 2011] [error] [client 131.91.19.188] PHP Warning: include(adodb/adodb-exceptions.inc.php): failed to open stream: No such file or directory in /var/www/skylease/getacCity.php on line 4, referer: http://lampserver01.vitessews.net/skylease/lease.html
[Fri Jan 07 13:04:57 2011] [error] [client 131.91.19.188] PHP Warning: include(): Failed opening 'adodb/adodb-exceptions.inc.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/skylease/getacCity.php on line 4, referer: http://lampserver01.vitessews.net/skylease/lease.html
[Fri Jan 07 13:04:57 2011] [error] [client 131.91.19.188] PHP Fatal error: Call to undefined function NewADOConnection() in /var/www/skylease/getacCity.php on line 12, referer: http://lampserver01.vitessews.net/skylease/lease.html
[Fri Jan 07 13:07:34 2011] [error] [client 109.230.251.8] File does not exist: /var/www/error

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

El 07/01/11 19:25, Stephen Mansfield escribió:
> Need some help...I included /usr/share/php5:/usr/share/pear in my $PATH
> command but did not fix the problem. I have pasted the error message
> below. Does anyone know where adodb/adodb.inc.php is located?

Probably you are trying to execute something missing. You'll need to
install the dependences your program needs

HTH
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk0nXWMACgkQk9xSKJO/Y0FlpACeLzrIeZpZRUG8EssOQNC67SZY
1pgAnRrRO9T3GjGOx8cNra68D4lhuvCj
=C+se
-----END PGP SIGNATURE-----

I am clearly missig something. I did check my dependancies. I am not saying that I am 100% correct in checking the dependancies. It's just that I am stuck. I have been working on this problem for 3 days and I am running out of what to check. Does anyone know where adodb/adodb.inc.php is located?

Ok, HTH saved the day. The root problem as stated above was that PHP could not find 'adodb/adodb.inc.php. I took a look at the link that HTH provided. It listed several libraries. The one that I needed was libphp-adodb. I am re-pasting HTH's search link,

http://packages.ubuntu.com/search?searchon=contents&keywords=adodb.inc.php&mode=exactfilename&suite=maverick&arch=any

I then installed libphp-adodb with the following command,

sudo apt-get install libphp-adodb

That was it...It fixed the problem. I appreciate everyone's help.

Thanks,
Steve Mansfield

Thanks Hilario J. Montoliu (hjmf), that solved my question.

Hi Steve

I am so glad you posted this problem and its solution. I was having exactly the same issue. i am going to try your solution and see if it works for me.

thanks and regards,
andrew

Hello Andrew,

Sorry for the late response. I am transitioning to a new notebook and have
not gotten all my email settled yet. Make sure you check around some of the
other blogs on this problem. I spent about 4 days trying to figure it out.
Make sure that your php daemon is running. If you go on the php site there
is info on how to check to make sure php is up and running. Also make sure
sql is working. You should be at least able to log into mysql and set up a
database. Finally check to make sure using that the daemon is actually not
running by typing ps aux | grep mysql. If the daemon is not running you
will not see any sql daemons running. Don't be fooled by the actual ps
command daemon that has mysql in the argument. My issue was the 4 files
that were not installed by the ubuntu installer as highligted in my posting.
It's been about 3 months since I worked on this problem so some of it is a
little fuzzy. By the way 10.10LTS is a good ubuntu release. I was using
10.04LTS and had a number of problems. I actually stopped using ubuntu for
3 or 4 months until the 10.10LTS release came out. I have not checked what
the latest releases are but again check the blogs to verify what kind of
experience people are having with ubuntu. Word on the blogs is they have a
new guy managing the releases. The quality of the releases under his
management has not been good. Good luck.
Regards,
Steve Mansfield

-----Original Message-----
From: andrew prudente
Sent: Wednesday, March 23, 2011 7:54 PM
To: <email address hidden>
Subject: Re: [Question #140562]: php cannot connect to mysql

Your question #140562 on php5 in Ubuntu changed:
https://answers.launchpad.net/ubuntu/+source/php5/+question/140562

andrew prudente posted a new comment:
Hi Steve

I am so glad you posted this problem and its solution. I was having
exactly the same issue. i am going to try your solution and see if it
works for me.

thanks and regards,
andrew

--
You received this question notification because you are a direct
subscriber of the question.

Hello Andrew,

Sorry for the late response. I am transitioning to a new notebook and have
not gotten all of my email settled yet. Make sure you check around some of
the
other blogs on this problem. I spent about 4 days trying to figure it out.
Make sure that your php daemon is running. If you go on the php site there
is info on how to check to make sure php is up and running. Also make sure
sql is working. You should be at least able to log into mysql and set up a
database. Finally check to make sure using that the daemon is actually not
running by typing ps aux | grep mysql. If the daemon is not running you
will not see any sql daemons running. Don't be fooled by the actual ps
command daemon that has mysql in the argument. My issue was the 4 files
that were not installed by the ubuntu installer as highligted in my posting.
It's been about 3 months since I worked on this problem so some of it is a
little fuzzy. By the way 10.10LTS is a good ubuntu release. I was using
10.04LTS and had a number of problems. I actually stopped using ubuntu for
3 or 4 months until the 10.10LTS release came out. I have not checked what
the latest releases are but again check the blogs to verify what kind of
experience people are having with ubuntu. Word on the blogs is they have a
new guy managing the releases. The quality of the releases under his
management has not been good. Good luck.
Regards,
Steve Mansfield

-----Original Message-----
From: andrew prudente
Sent: Wednesday, March 23, 2011 7:54 PM
To: <email address hidden>
Subject: Re: [Question #140562]: php cannot connect to mysql

Your question #140562 on php5 in Ubuntu changed:
https://answers.launchpad.net/ubuntu/+source/php5/+question/140562

andrew prudente posted a new comment:
Hi Steve

I am so glad you posted this problem and its solution. I was having
exactly the same issue. i am going to try your solution and see if it
works for me.

thanks and regards,
andrew

--
You received this question notification because you are a direct
subscriber of the question.

Micah Gersten (micahg) said : #13

Please note 10.10 is NOT an LTS release. 12.04 will be the next LTS release.