I am trying to connect to a mysql db through php running on my schools unix server. This is what I am trying:
$ php setupDatabase.php
PHP Fatal error: Call to undefined function mysql_connect() in /users/cs/summers/Fall2010/webCentric/ass4/sessionTime/setupDatabase.php on line 16
Line 16 refers to this line:
db_server = mysql_connect($db_hostname, $db_username, $db_password);
I think this means that the mysql functions where not installed with php. When I execute <?php phpinfo(); exit(); ?> and grep for mysql this is what I get:
Configure Command => './configure' '--build=x86_64-redhat-linux-gnu' '--host=x86_64-redhat-linux-gnu' ... '--with-mysql=shared,/usr' '--with-mysqli=shared,/usr/bin/mysql_config' '--with-pdo-mysql=shared,/usr' ...
I am not sure if this confirms that mysql is not installed.
Q: Am I missing mysql? Do I need to reinstall php with mysql?
Q: I do not have root access to server (obviously). Will I be able to install this without root access? If yes could someone point me to a tutorial?
Update
I just looked in my php.ini file this is what is contained in it regarding the mysql (I have removed comments and mysqli stuff).
[MySQL]
mysql.allow_persistent = Off
mysql.max_persistent = -1
mysql.max_links = -1
mysql.default_port =
mysql.default_socket =
mysql.default_host =
mysql.default_user =
mysql.default_password =
mysql.connect_timeout = 60
mysql.trace_mode = Off
The file does NOT contain: extension=mysql.so is this what is required to enable mysql? I do not have permissions to modify php.ini can I create another one somewhere or can I use something like an include statement with my code?
You have mysql extension disabled on your php.ini.
Edit your php.ini and uncomment (remove the 😉
In case you can’t edit php.ini, you can override it this way.