Reputation: 71
PHP MySQL on my Ubuntu server works fine in Apache, but not in CLI
This happened after a botched upgrade attempt from 5.3 to 5.6 (the upgrade didn't replace 5.3 but installed 5.6 alongside. php -v shows 5.6, but phpinfo shows 5.3!)
I get the error PHP Fatal error: Call to undefined function mysql_query()
I have tried many steps: symlinking the apache's config to the cli directory so they match, making sure mysql module is listed in phpinfo which it is, adding extension=mysql.so or extension=php_mysql.so or extension=/usr/lib/php5/20090626/mysql.so (and all directories that have mysql.so in), none of which work.
I don't know where to go from here. Yes I know I should use mysqli but I haven't got time right now to recode hundreds of pages to use mysqli.
UPDATE: I changed one file to mysqli and even that isn't working in CLI: Call to undefined function mysqli_connect()
Thanks
Upvotes: 0
Views: 2062
Reputation: 71
I've fixed this now, as the CLI PHP version was 5.6, upon installing php-mysql I had to specify the version apt-get install php5.6-mysql
Upvotes: 1
Reputation: 1144
Yes, you have to use mysqli_query instead of mysql_query
mysql_connect will be replaced by mysqli_connect mysql_query will be replaced by mysqli_query($con, $query)
Upvotes: 0