The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> System Administration
> Apache Development
|
Mysql_connect failure
Discuss Mysql_connect failure in the Apache Development forum on Dev Shed. Mysql_connect failure Apache Development forum discussing HTTP Server general topics, configuration, and modules. Apache is an open source web server that runs on multiple platforms.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

November 5th, 2012, 10:16 PM
|
|
Registered User
|
|
Join Date: Nov 2012
Posts: 8
Time spent in forums: 5 h 15 m 36 sec
Reputation Power: 0
|
|
|
Mysql_connect failure
Hi. Up until this point I have had mysql, php, and apache up and running just fine. Recently I made a little change. I configured Apache to read my .php pages from /home/user/code/php instead of /srv/http. It wasn't working originally so I created a new http user using this command:
Code:
useradd -d /srv/http -r -s /bin/false -U http
And replaced /srv/http with the directory of my choice. Almost everything went fine. I was able to see all my .php files. The problem was with one file. This is the code for it:
Code:
<?php
mysql_connect("localhost", "root", "mypass") or die(mysql_error());
echo "Connected to MySQL<br />";
?>
Originally it displayed everything fine but once I made the switch it displayed this error:
Code:
Fatal error: Call to undefined function mysql_connect() in /home/'user'/code/php/connect.php on line 2
I tried to login to phpMyAdmin as well and this error is displayed:
Code:
The mysqli extension is missing. Please check your PHP configuration. <a href="Documentation.html#faqmysql" target="documentation"><img src="themes/dot.gif" title="Documentation" alt="Documentation" class="icon ic_b_help" /></a>
Not sure if it matters but I have made the switch to a systemd only installation and have run systemctl enable httpd.service, systemctl enable mysqld.service, systemctl start httpd.service, and systemctl start mysql.service countless times just to be sure. I have also made sure that
Code:
extension=mysqli.so
extension=mysql.so
Are both uncommented in /etc/php/php.ini
|

November 5th, 2012, 10:21 PM
|
 |
Still alive
|
|
Join Date: Mar 2007
Location: Washington, USA
|
|
|
Use phpinfo() to see which php.ini is being parsed. Also check error logs for messages from PHP - maybe about being unable to load extensions.
|

November 5th, 2012, 10:33 PM
|
|
Registered User
|
|
Join Date: Nov 2012
Posts: 8
Time spent in forums: 5 h 15 m 36 sec
Reputation Power: 0
|
|
Quote: | Originally Posted by requinix Use phpinfo() to see which php.ini is being parsed. Also check error logs for messages from PHP - maybe about being unable to load extensions. |
I'm sorry, I'm pretty new to LAMP. But here's what I'm thinking you want me to look at:
(oops, didn't realize I couldn't do that)
Anyway, It says that there are no additional .ini files parsed besides php.ini. There are no files in conf.d..
|

November 6th, 2012, 12:53 AM
|
 |
Still alive
|
|
Join Date: Mar 2007
Location: Washington, USA
|
|
You can post URLs, just don't make them look like URLs
What phpinfo() will tell you is the exact location of the php.ini it's using. That's where you need to make sure the extension= lines are.
Also, with Apache you need to restart it when you make php.ini changes (or other significant changes). Settings won't take effect until you do.
As for errors, check Apache's error log. And maybe some of the other /var/log files.
|

November 6th, 2012, 01:57 PM
|
|
Registered User
|
|
Join Date: Nov 2012
Posts: 8
Time spent in forums: 5 h 15 m 36 sec
Reputation Power: 0
|
|
Quote: | Originally Posted by requinix You can post URLs, just don't make them look like URLs
What phpinfo() will tell you is the exact location of the php.ini it's using. That's where you need to make sure the extension= lines are.
Also, with Apache you need to restart it when you make php.ini changes (or other significant changes). Settings won't take effect until you do.
As for errors, check Apache's error log. And maybe some of the other /var/log files. |
Ah I see:
ht tp://i.imgur.com/O1iKN.png
I'm hoping that is the relevant part of phpinfo(). Also, I'm not sure if this is relevant but:
Code:
; Directory in which the loadable extensions (modules) reside.
; http://php.net/extension-dir
extension_dir = "/usr/lib/php/modules/"
; On windows:
; extension_dir = "ext"
|

November 6th, 2012, 02:42 PM
|
 |
Still alive
|
|
Join Date: Mar 2007
Location: Washington, USA
|
|
|
Then you're editing the right file. Make sure you're restarting Apache after you make php.ini changes and check its logs (/var/log/apache* probably) for errors.
|

November 6th, 2012, 05:12 PM
|
|
Registered User
|
|
Join Date: Nov 2012
Posts: 8
Time spent in forums: 5 h 15 m 36 sec
Reputation Power: 0
|
|
Quote: | Originally Posted by requinix Then you're editing the right file. Make sure you're restarting Apache after you make php.ini changes and check its logs (/var/log/apache* probably) for errors. |
I've restarted relentlessly...I will check phpinfo() more. It obviously has something to do with the fact that I temporarily changed the Document_root for user http.
EDIT: I don't suppose I could do something so simple as reinstalling could I?
UPDATE: Fixed the errors. It was a simple random syntax error in the /etc/php/php.ini file. Found it after running php -m. I can't believe I didn't try that sooner. *facepalm*
The only trouble now is that I can't get php to display any errors. I definitely have it enable in /etc/php/php.ini:
Code:
error_reporting
error_reporting E_ERROR E_WARNING E_PARSE
Default Value: E_ALL E_NOTICE E_STRICT E_DEPRECATED
Development Value: E_ALL
Production Value: E_ALL E_DEPRECATED E_STRICT
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|