undefined function mysql_connect

Started by mweed, December 28, 2018, 04:02:12 PM

Previous topic - Next topic

mweed

I'm attempting to migrate my forums to a new server.  Got all the forum files copied and the database setup and running.  Everything looks good and checks out, but when I try to access, I get a completely blank page.  When I check, the error_log in the forum root folder, I see the following error message:

[28-Dec-2018 20:31:08 UTC] PHP Fatal error:  Uncaught Error: Call to undefined function mysql_connect() in /home/xxx/public_html/forums/Sources/Subs-Db-mysql.php:67
Stack trace:
#0 /home/xxx/public_html/forums/Sources/Load.php(2666): smf_db_initiate('localhost', 'database-name...', 'user-name', 'user-password', 'smf_', Array)
#1 /home/xxx/public_html/forums/index.php(77): loadDatabase()
#2 {main}


So it looks like it's not even trying to connect to the database because it can't find function.  I'm guessing there's a file missing or something not set right.  But I don't know where to look.

Also, don't know why the database name has those three dots after it.  They aren't there in Settings.php

vbgamer45

Are you on SMF 2.0.15?
2.014 and higher support PHP 7+
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

mweed

SMF 2.0.15
cPanel claims it's running PHP 7.2, however phpMyAdmin says the web server PHP version is 5.6.30
mySQL server verison 5.6.39-cll-lve

vbgamer45

in cpanel goto the multiphp manager and make sure you apply PHP 7.1 to your site. that is the best version for SMF 2.0.15
Or downgrade to SMF 2.0.13 to support PHP 5.6
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

mweed

#4
Tried 7.1 and 7.0, had the same problem.
Dropped to 5.6 and now I get the "Access denied for user 'user-name'@'localhost' (using password: NO)" error.  That error seems fairly common from a forum search.  But having to back down to 5.6 is Very odd.  One of the reasons I switched servers was to move to a newer version of PHP.

I'll start looking at the password now that the function is found. 

UPDATE:  Reset the password and everything is up and running under PHP 5.6, cannot find function under any PHP version 7.0+

GigaWatt

Have you tried adjusting PHP extensions in cPanel?
"This is really a generic concept about human thinking - when faced with large tasks we're naturally inclined to try to break them down into a bunch of smaller tasks that together make up the whole."

"A 500 error loosely translates to the webserver saying, "WTF?"..."

mweed

NO.  Which ones should I change?   It appears that when I move from 5.6 to 7.x the mysql extension is no longer an option, just mysqli and mysqlnd.

vbgamer45

Yes it is only  just mysqli and mysqlnd after php 5.6 as long on latest SMF should be ok.
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

GigaWatt

You mean you're not getting this screen when you go to PHP Selector?



How about MultiPHP Manager? Do you have something like that in your cPanel?
"This is really a generic concept about human thinking - when faced with large tasks we're naturally inclined to try to break them down into a bunch of smaller tasks that together make up the whole."

"A 500 error loosely translates to the webserver saying, "WTF?"..."

mweed


GigaWatt

Try ticking the pdo_pgsql extension, see if that works ;).
"This is really a generic concept about human thinking - when faced with large tasks we're naturally inclined to try to break them down into a bunch of smaller tasks that together make up the whole."

"A 500 error loosely translates to the webserver saying, "WTF?"..."

mweed

Nope.  That didn't change the situation.  Function still not found.

vbgamer45

Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

Arantor

Quote from: GigaWatt on December 28, 2018, 05:49:29 PM
Try ticking the pdo_pgsql extension, see if that works ;).

pdo_pgsql would give you Postgres support, assuming the base PDO library were installed - but SMF uses neither of these.

Thing is, if it's still complaining about mysql_connect not being found, adding mysqli isn't going to fix anything - something is still trying to make that connection even though the underlying library has been removed. SMF 2.0.14 doesn't use mysql_connect, so either a really badly written mod or custom page is trying to use it...

mweed

It's not a mod or a custom page, it's the main index.php
index.php is listed as version 2.0.15
On page load, index.php line 77 calls the loadDatabase() function from Sources/load.php that was included on line 61.

Load.php lists the version as 2.0.14
Load.php line 2666 calls smf_db_initiate()
// Either we aren't in SSI mode, or it failed.
if (empty($db_connection))
$db_connection = smf_db_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, array('persist' => $db_persist, 'dont_select_db' => SMF == 'SSI'));


This function call is being pointed to Sources/Subs_Db_Mysql.php
Subs_Db_Mysql.php lists the version as 2.0.14
Subs_Db_Mysql.php lines 64 to 67 calls the offending function
if (!empty($db_options['persist']))
$connection = @mysql_pconnect($db_server, $db_user, $db_passwd);
else
$connection = @mysql_connect($db_server, $db_user, $db_passwd);


My guess is somewhere along the update process, one of the files didn't get updated correctly.

mweed

Found the problem in Subs_Db_Mysql.php

Lines 29 to 36 do a check for MySQLi.  These lines were commented out.  Once I removed them from being a comment, the function recognizes that the MySQLi extension is loaded and uses that instead of the MySQL.

Now the site works fine with PHP 7.1 :)

Advertisement: