You are not logged in.

#1 2012-03-22 04:31:04

clandest
Member
Registered: 2012-03-16
Posts: 22

getting Fatal error: Call to undefined function mysql_connect() error.

ok, so before I had my mysql_connect php script and it ran fine, no errors, but once I changed my php.ini file to give ERROR_REPORTING E_ALL I now get Fatal error: Call to undefined function mysql_connect(). I am just wondering how I can fix this?

I followed the arch linux LAMP wiki and I can't figure out why I am getting this error after turnning on error_reporting.

Thanks

this is my php code

 <?php

$connection = mysql_connect('localhost', 'root', 'password');

if(!$connection){
  echo mysql_error();
} else {
  echo 'connected'; 
}

if (!mysql_select_db('my_first_db')){
  echo 'uh';
} else {
  echo 'selected database';
}

?>
 
 <?php phpinfo(); ?>

Last edited by clandest (2012-03-22 04:36:43)

Offline

#2 2012-03-22 04:45:24

astiak
Member
From: London, UK
Registered: 2010-12-14
Posts: 16

Re: getting Fatal error: Call to undefined function mysql_connect() error.

Can you verify whether the following two lines in your php.ini have been uncommented?

;extension=mysqli.so
;extension=mysql.so

If not, uncomment both, restart apache and it should resolve your issue.

Offline

#3 2012-03-22 16:21:48

clandest
Member
Registered: 2012-03-16
Posts: 22

Re: getting Fatal error: Call to undefined function mysql_connect() error.

astiak wrote:

Can you verify whether the following two lines in your php.ini have been uncommented?

;extension=mysqli.so
;extension=mysql.so

If not, uncomment both, restart apache and it should resolve your issue.

yes, both of those were uncommented. I made sure to check that when the problem occurred.

Thanks

Offline

#4 2012-03-22 17:50:56

astiak
Member
From: London, UK
Registered: 2010-12-14
Posts: 16

Re: getting Fatal error: Call to undefined function mysql_connect() error.

Your php code is absolutely fine.

Do you have the mysql modules showing up in the output of "php -m"?

Offline

#5 2012-03-22 17:52:19

clandest
Member
Registered: 2012-03-16
Posts: 22

Re: getting Fatal error: Call to undefined function mysql_connect() error.

astiak wrote:

Your php code is absolutely fine.

Do you have the mysql modules showing up in the output of "php -m"?


This is what it prints out

PHP:  syntax error, unexpected '&' in /etc/php/php.ini on line 510
[PHP Modules]
Core
ctype
date
dom
ereg
fileinfo
filter
hash
libxml
mbstring
mhash
mysqlnd
pcntl
pcre
PDO
readline
Reflection
session
SimpleXML
SPL
standard
tokenizer
xml
xmlreader
xmlwriter
zlib

[Zend Modules]

Offline

#6 2012-03-22 18:52:05

astiak
Member
From: London, UK
Registered: 2010-12-14
Posts: 16

Re: getting Fatal error: Call to undefined function mysql_connect() error.

Hmm yes, it appears the mysql modules have failed to load, would you mind copying your php.ini to a pastebin site?

Offline

#7 2012-03-22 21:26:23

clandest
Member
Registered: 2012-03-16
Posts: 22

Re: getting Fatal error: Call to undefined function mysql_connect() error.

oh ... heres the php.ini

http://pastebin.com/bVEs1Xii

thanks!

Offline

#8 2012-03-22 21:52:23

aking9
Member
Registered: 2009-03-30
Posts: 65

Re: getting Fatal error: Call to undefined function mysql_connect() error.

grabbing into the back of the back of my memory here but don't you need to specify a port to connect to?

Offline

#9 2012-03-22 23:23:07

astiak
Member
From: London, UK
Registered: 2010-12-14
Posts: 16

Re: getting Fatal error: Call to undefined function mysql_connect() error.

aking9 wrote:

grabbing into the back of the back of my memory here but don't you need to specify a port to connect to?

Only if you change the port from the default 3306. But even then, a different error message will output, in this case the mysql modules have not loaded for some reason.

There is a syntax error in your php.ini file, at line 510. Comment out this line as it's a line giving information rather than an option. Then uncomment the error_reporting option.

So this:

 Default Value: E_ALL & ~E_NOTICE
; Development Value: E_ALL | E_STRICT
; Production Value: E_ALL & ~E_DEPRECATED
; http://php.net/error-reporting
;error_reporting = E_ALL & ~E_DEPRECATED

Should be changed to this:

; Default Value: E_ALL & ~E_NOTICE
; Development Value: E_ALL | E_STRICT
; Production Value: E_ALL & ~E_DEPRECATED
; http://php.net/error-reporting
error_reporting = E_ALL & ~E_DEPRECATED

After this try "sudo /etc/rc.d/httpd restart" then see if you have any better luck connecting to mysql.

Last edited by astiak (2012-03-22 23:24:40)

Offline

#10 2012-03-23 01:42:56

clandest
Member
Registered: 2012-03-16
Posts: 22

Re: getting Fatal error: Call to undefined function mysql_connect() error.

all good, thank you astiak

Offline

#11 2012-03-23 03:45:37

astiak
Member
From: London, UK
Registered: 2010-12-14
Posts: 16

Re: getting Fatal error: Call to undefined function mysql_connect() error.

No problem at all, glad i could be of help.

Offline

Board footer

Powered by FluxBB