Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.6k views
in Technique[技术] by (71.8m points)

xampp php 7 Call to undefined functions (mysql & odbc)

I updated my xampp to a new version, which now includes php7 all my scripts don't work anymore.

I found here some "solutions" which don't works.

I get these messages:

Fatal error: Uncaught Error: Call to undefined function odbc_connect() Fatal error: Uncaught Error: Call to undefined function mysql_connect()

I have the extensions in my php.ini

extension=php_bz2.dll
extension=php_curl.dll
extension=php_fileinfo.dll
extension=php_gd2.dll
extension=php_gettext.dll
;extension=php_gmp.dll
;extension=php_intl.dll
;extension=php_imap.dll
;extension=php_interbase.dll
;extension=php_ldap.dll
extension=php_mbstring.dll
extension=php_exif.dll     
extension=php_mysql.dll
extension=php_mysql_libmysql.dll
extension=php_mysql_mysqlnd.dll
extension=php_mysqli.dll
;extension=php_oci8_12c.dll
;extension=php_openssl.dll
;extension=php_pdo_firebird.dll
extension=php_pdo_mysql.dll
;extension=php_pdo_oci.dll
extension=php_pdo_odbc.dll
;extension=php_pdo_pgsql.dll
extension=php_pdo_sqlite.dll
;extension=php_pgsql.dll
;extension=php_shmop.dll
;extension=php_snmp.dll
;extension=php_soap.dll
;extension=php_sockets.dll
;extension=php_sqlite3.dll
;extension=php_tidy.dll
;extension=php_xmlrpc.dll
;extension=php_xsl.dll

I saved the php.ini and restarted my apache - but the result is the same.

Any ideas? :(

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

if still interested, in case u got old source with many mysql_ functions you could use wrapper functions for mysqli and then include it in any file that uses mysql_ funtions.The Wrapper file may could look like: (may some functions are missing, as this was all functions i used in mysql_)

<?php
if (PHP_VERSION_ID > 59999) 
{
    function mysql_connect($a,$b,$c,$d=null) { return mysqli_connect($a,$b,$c,$d); }
    function mysql_query($a,$b) { return mysqli_query($b,$a); }
    function mysql_affected_rows($a) { return mysqli_affected_rows($a); }
    function mysql_close($a) { return mysqli_close($a); }
    function mysql_fetch_assoc($a) { return mysqli_fetch_assoc($a); }
    function mysql_free_result ($a) { mysqli_stmt_free_result($a); }
    function mysql_select_db ($a,$b) { mysqli_select_db($b,$a); }
}

?>

I used above code to quickly migrate some old dirty scripts with many mysql_querys in them. As you got enabled the mysqli extension in your ini-file, it should work for you either.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...