You are not logged in.

#1 2012-11-06 02:24:52

xworld
Member
Registered: 2012-05-27
Posts: 153

[SOLVED]Call to undefined function mysql_connect()

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:

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:

<?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:

 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:

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

extension=mysqli.so
extension=mysql.so

Are both uncommented in /etc/php/php.ini

Last edited by xworld (2012-11-08 00:48:14)

Offline

#2 2012-11-06 13:45:51

yaffare
Member
Registered: 2011-12-29
Posts: 71

Re: [SOLVED]Call to undefined function mysql_connect()

please run phpinfo(); and post that. The mysql.so module is definitely not loaded.
Do you have extension_dir = "/usr/lib/php/modules/" in php.ini? Does the file /usr/lib/php/modules/mysql.so exist?
If so apache must be using a different php.ini than /etc/php/php.ini. You can see that in phpinfo. (Loaded Configuration File)


systemd is like pacman. enjoys eating up stuff.

Offline

#3 2012-11-06 19:53:30

xworld
Member
Registered: 2012-05-27
Posts: 153

Re: [SOLVED]Call to undefined function mysql_connect()

Here's phpinfo():

Linux net 3.6.6-1-ARCH #1 SMP PREEMPT Mon Nov 5 11:57:22 CET 2012 x86_64
Build Date 	Oct 17 2012 20:31:37
Configure Command 	'./configure' '--srcdir=../php-5.4.8' '--config-cache' '--prefix=/usr' '--sysconfdir=/etc/php' '--localstatedir=/var' '--with-layout=GNU' '--with-config-file-path=/etc/php' '--with-config-file-scan-dir=/etc/php/conf.d' '--disable-rpath' '--mandir=/usr/share/man' '--without-pear' '--disable-cli' '--with-apxs2' '--enable-bcmath=shared' '--enable-calendar=shared' '--enable-dba=shared' '--enable-exif=shared' '--enable-ftp=shared' '--enable-gd-native-ttf' '--enable-intl=shared' '--enable-mbstring' '--enable-phar=shared' '--enable-posix=shared' '--enable-shmop=shared' '--enable-soap=shared' '--enable-sockets=shared' '--enable-sysvmsg=shared' '--enable-sysvsem=shared' '--enable-sysvshm=shared' '--enable-zip=shared' '--with-bz2=shared' '--with-curl=shared' '--with-db4=/usr' '--with-enchant=shared,/usr' '--with-freetype-dir=/usr' '--with-gd=shared' '--with-gdbm' '--with-gettext=shared' '--with-gmp=shared' '--with-iconv=shared' '--with-icu-dir=/usr' '--with-imap-ssl' '--with-imap=shared' '--with-jpeg-dir=/usr' '--with-vpx-dir=/usr' '--with-ldap=shared' '--with-ldap-sasl' '--with-mcrypt=shared' '--with-mhash' '--with-mssql=shared' '--with-mysql-sock=/var/run/mysqld/mysqld.sock' '--with-mysql=shared,mysqlnd' '--with-mysqli=shared,mysqlnd' '--with-openssl=shared' '--with-pcre-regex=/usr' '--with-pdo-mysql=shared,mysqlnd' '--with-pdo-odbc=shared,unixODBC,/usr' '--with-pdo-pgsql=shared' '--with-pdo-sqlite=shared,/usr' '--with-pgsql=shared' '--with-png-dir=/usr' '--with-pspell=shared' '--with-snmp=shared' '--with-sqlite3=shared,/usr' '--with-tidy=shared' '--with-unixODBC=shared,/usr' '--with-xmlrpc=shared' '--with-xsl=shared' '--with-zlib'
Server API 	Apache 2.0 Handler
Virtual Directory Support 	disabled
Configuration File (php.ini) Path 	/etc/php
Loaded Configuration File 	/etc/php/php.ini
Scan this dir for additional .ini files 	/etc/php/conf.d
Additional .ini files parsed 	(none)
PHP API 	20100412
PHP Extension 	20100525
Zend Extension 	220100525
Zend Extension Build 	API220100525,NTS
PHP Extension Build 	API20100525,NTS
Debug Build 	no
Thread Safety 	disabled
Zend Signal Handling 	disabled
Zend Memory Manager 	enabled
Zend Multibyte Support 	provided by mbstring
IPv6 Support 	enabled
DTrace Support 	disabled
Registered PHP Streams	compress.zlib, php, file, glob, data, http, ftp
Registered Stream Socket Transports	tcp, udp, unix, udg
Registered Stream Filters	zlib.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, dechunk

Sorry if there is a better way to post this. If so I'm willing to fix it. I posted the part that I thought was relevant

I do have extension_dir="/usr/lib/php/modules:

; Directory in which the loadable extensions (modules) reside.
; http://php.net/extension-dir
extension_dir = "/usr/lib/php/modules/"
; On windows:
; extension_dir = "ext"

Also, the file /usr/lib/php/modules/mysql.so does exist.

Offline

#4 2012-11-06 22:04:43

yaffare
Member
Registered: 2011-12-29
Posts: 71

Re: [SOLVED]Call to undefined function mysql_connect()

this may be stupid, but did you restart the webserver, after changing php.ini?
otherwise search for mysql in the phpinfo(); if the module is loaded its listed there

Last edited by yaffare (2012-11-06 22:05:22)


systemd is like pacman. enjoys eating up stuff.

Offline

#5 2012-11-06 23:11:34

xworld
Member
Registered: 2012-05-27
Posts: 153

Re: [SOLVED]Call to undefined function mysql_connect()

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*

Last edited by xworld (2012-11-08 00:47:48)

Offline

Board footer

Powered by FluxBB