You are not logged in.
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
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
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
Your php code is absolutely fine.
Do you have the mysql modules showing up in the output of "php -m"?
Offline
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
Hmm yes, it appears the mysql modules have failed to load, would you mind copying your php.ini to a pastebin site?
Offline
Offline
grabbing into the back of the back of my memory here but don't you need to specify a port to connect to?
Offline
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
all good, thank you astiak
Offline
No problem at all, glad i could be of help.
Offline