0

I recently moved from one dedicated to the next. I'm using the same repos for my apache, mysql, and php installations. However, when attempting to load a known-good file, php is unable to handle the request.

It is very basic mysql queries, just loads a blank white page.

As well, when trying to install WordPress, using the correct information, the webserver is unable to connect to the intended remote installation database.

php-mysql and -mysqli have been installed.

Using CentOS 6.2, Apache 2.2.15, PHP 5.3.10, and Zend 2.3.0.

Edit1:

I want to add that if I call the file from terminal, using "php file.php" - it performs as expected. Its just when apache gets involved that there is a problem. Otherwise, this is the error in /var/log/httpd pastie.org/3814963 To note, it's not being told to use root. Neither is it being told to use localhost. pastie.org/3814965

Edit2: php is not set in safe mode.

5
  • is php enabled on Apache and also if Php has mysql enabled? Commented Apr 19, 2012 at 5:22
  • 2
    service mysqld start | service httpd restart. Beyond that, you've got Zend, and you've got your Web error logs. You should be able to glean way more information than we can from the outside. Commented Apr 19, 2012 at 5:24
  • Is php_mysql and php_mysqli enabled in the PHP ini? Commented Apr 19, 2012 at 5:24
  • firstly add error_reporting(E_ALL) to your script, that will spit out an error and not just a blank page, plus check the servers listening on the correct ports with shell $# sudo netstat --tcp --listening --programs Commented Apr 19, 2012 at 5:36
  • I want to add that if I call the file from terminal, using "php file.php" - it performs as expected. Its just when apache gets involved that there is a problem. Otherwise, this is the error in /var/log/httpd pastie.org/3814963 To note, it's not being told to use root. Neither is it being told to use localhost. pastie.org/3814965 Commented Apr 19, 2012 at 6:03

1 Answer 1

1

My guess from your looking at your code, the error message, and the documentation for mysql_connect that your server has safe_mode enabled.

http://php.net/manual/en/function.mysql-connect.php

The relevant part:

server

The MySQL server. It can also include a port number. e.g. "hostname:port" or a path to a local socket e.g. ":/path/to/socket" for the localhost. If the PHP directive mysql.default_host is undefined (default), then the default value is 'localhost:3306'. In SQL safe mode, this parameter is ignored and value 'localhost:3306' is always used.

username

The username. Default value is defined by mysql.default_user. In SQL safe mode, this parameter is ignored and the name of the user that owns the server process is used. password

password

The password. Default value is defined by mysql.default_password. In SQL safe mode, this parameter is ignored and empty password is used.

Edit your PHP.INI file and set safe_mode to off.

Sign up to request clarification or add additional context in comments.

3 Comments

safe_mode = Off safe_mode_gid = Off safe_mode_include_dir = safe_mode_exec_dir = safe_mode_allowed_env_vars = PHP_ safe_mode_protected_env_vars = LD_LIBRARY_PATH ;open_basedir = disable_functions = disable_classes =
Run a phpinfo() and check the status of safe mode in there. Safe mode is the only thing that makes sense; the results you're getting exactly fit that situation. It will ignore the parameters and connect to localhost with root as the username and no password in that situation. Exactly as you are seeing here.
Checking the php.ini file is not sufficient to ensure safe_mode isd disabled. It could be enabled in the Apache configuration or even in an .htaccess file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.