|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Fatal error: Call to undefined function: mysql_connect()
On this machine PHP is unable to connect to MySQL.
Debian linux kernel 2.2.19 PHP version 4.0.3pl1, MySQL distribution 3.22.32 on port 3306. The PHP string $link = mysql_connect( "localhost", "user", "password" ) produces this error message Fatal error: Call to undefined function: mysql_connect() The user & password are correct. Replacing "localhost" with the IP number produces the same error. Perl connects perfectly to mysql with the DBI module: DBI->connect PHP works perfectly with other functions. phpinfo shows this configure command: ../configure' '--prefix=/usr' '--with-apxs=/usr/bin/apxs' '--with-regex=system' '--with-config-file-path=/etc/php4/apache' '--enable-calendar' '--with-db' '--without-dom' '--enable-filepro' '--enable-ftp' '--with-gettext' '--enable-sysvsem' '--enable-sysvshm' '--enable-track-vars' '--enable-trans-sid' '--disable-debug' '--disable-static' '--with-gd=shared' '--with-imap=shared' '--with-ldap=shared,/usr' '--with-mm' '--with-mhash=shared' '--with-mysql=shared,/usr' '--with-regex=system' '--with-pcre-regex=/usr' '--with-pgsql=shared,/usr' '--with-snmp=shared' '--enable-sockets' '--with-ttf' '--enable-freetype-4bit-antialias-hack' '--with-t1lib' '--with-xml=shared,/usr' '--with-yp' '--with-zlib' these loaded modules: mod_php4, mod_setenvif, mod_unique_id, mod_expires, mod_auth, mod_access, mod_rewrite, mod_alias, mod_userdir, mod_cgi, mod_dir, mod_autoindex, mod_include, mod_status, mod_negotiation, mod_mime, mod_log_config, mod_macro, mod_perl, mod_so, http_core Debian sometimes has some strange paths. The /etc/my.cnf file shows socket = /var/run/mysqld/mysqld.sock This symbolic link has to be made after reboot, before mysql will work: ln -s /var/run/mysqld/mysqld.sock /tmp/mysql.sock I plugged this socket value into /etc/php4/apache/php.ini: =================== ; Default port number for mysql_connect(). If unset, mysql_connect() will use ; the $MYSQL_TCP_PORT or the mysql-tcp entry in /etc/services or the ; compile-time value defined MYSQL_PORT (in that order). Win32 will only look ' at MYSQL_PORT. mysql.default_port = ; Default socket name for local MySQL connects. If empty, uses the built-in ; MySQL defaults. mysql.default_socket = /var/run/mysqld/mysqld.sock ; Default host for mysql_connect() (doesn't apply in safe mode). mysql.default_host = ; Default user for mysql_connect() (doesn't apply in safe mode). mysql.default_user = ; Default password for mysql_connect() (doesn't apply in safe mode). ; Note that this is generally a *bad* idea to store passwords in this file. ; *Any* user with PHP access can run 'echo cfg_get_var("mysql.default_password") ; and reveal this password! And of course, any users with read access to this ; file will be able to reveal the password as well. mysql.default_password = =================== Rebooted (again), still get the Fatal error. On another forum, this suggestion was made: "One thing to try: Look in php.ini for a line that reads something like ";extension=mysql.so" and uncomment it. " I did it, still no joy. I suspect that the mysql.so lib is not available to PHP, but I am not up to speed on PHP installation. My friend who did the install is unavailable. Is this like a Perl lib: /usr/local/lib/site_perl/i386-linux/auto/DBD/mysql/mysql.so Can the mysql.so be installed in a lib directory somewhere, or does apache/PHP need to be recompiled with the module present? Does anybody have any ideas? Thanks |
|
#2
|
|||
|
|||
|
RE: Fatal error: Call to undefined function: mysql_connect()
add this to the line and see if it shows any different errors.
$link = mysql_connect( "localhost", "user", "password" ) or die(mysql_error()); |
|
#3
|
|||
|
|||
|
RE: Fatal error: Call to undefined function: mysql_connect()
Hi
Had the same problem and found the solution here. http://www.vttoth.com/badmysql.htm If you are using Debian ... then find the propriety directory somewhere in /usr/lib/ goodluck mike |
|
#4
|
|||
|
|||
|
RE: Fatal error: Call to undefined function: mysql_connect()
i got the same message, and the fix at http://www.vttoth.com/badmysql.htm worked, but the file i had to edit was /etc/php.d/mysql.ini and put extension=mysql.so in there.
good luck! |
|
#5
|
|||
|
|||
|
RE: Fatal error: Call to undefined function: mysql_connect()
I have the same error, but i can't seem to find my mysql.ini and mysql.so files! BTW, I have RH 8 installed and PHP and MySQL where installed as RPM's... Thanks in advance guyz!
|
|
#6
|
|||
|
|||
|
RE: Fatal error: Call to undefined function: mysql_connect()
Your mysql.so file should be in /usr/lib/php4/mysql.so and there is no such thing as a mysql.ini file in linux that I know of. I thing you mean confuring it in the php.ini, don't you?
|
|
#7
|
|||
|
|||
|
RE: Fatal error: Call to undefined function: mysql_connect()
Hi,
I tried looking for mysql.so in the /usr/lib/php4 dir and it wasn't there... I tried searching for the mysql.so file and i found it at /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi/auto/DBD/mysql dir. I edited php.ini and specified the extension_dir to that dir, and also making sure the extension=mysql.so was uncommented. I restarted apache and still, same result... Should i move the mysql.so file to the /usr/lib/php4 dir? Thanks for the reply... |
|
#8
|
|||
|
|||
|
RE: Fatal error: Call to undefined function: mysql_connect()
Hi,
I tried looking for mysql.so in the /usr/lib/php4 dir and it wasn't there... I tried searching for the mysql.so file and i found it at /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi/auto/DBD/mysql dir. I edited php.ini and specified the extension_dir to that dir, and also making sure the extension=mysql.so was uncommented. I restarted apache and still, same result... Should i move the mysql.so file to the /usr/lib/php4 dir? Thanks for the reply... |
|
#9
|
|||
|
|||
|
RE: Fatal error: Call to undefined function: mysql_connect()
I was battling with this problem as well, this thread sent me on the right track, so thanks.
If anyone is still having the same problem and find the mysql.so in a perl-directory, here's the solution: You'll need to get php4-mysql package (apt-get install php4-mysql). After that, locate mytsql.so (for me, it was now also found in /usr/lib/php4/20010901/mysql.so). After that, change the extension_dir in php.ini to the new one. With this version of mysql.so set in php.ini, my MySQL connection started working perfectly. |
|
#10
|
|||
|
|||
|
RE: Fatal error: Call to undefined function: mysql_connect()
thx i had the same problem but now in works fine.
thank you all. |
![]() |
| Viewing: Codewalkers Forums > PHP Related > PHP Installation > Fatal error: Call to undefined function: mysql_connect() |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|