FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » cant use mysql_connect
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
cant use mysql_connect [message #179434] Sun, 28 October 2012 16:30 Go to next message
Markus Grob is currently offline  Markus Grob
Messages: 9
Registered: September 2011
Karma: 0
Junior Member
Hello together

I have changed to Apache 2.4 with PHP 5.4 and MySQL 5.5. MySQL is
running and all databases were imported from the earlier version.
Apache is running and php_info gives me the hint, that mysqlnd was found:

PHP Version 5.4.4

System Windows NT KRWM0023 6.1 build 7601 (Windows 7 Enterprise Edition
Service Pack 1) i586
Build Date Jun 13 2012 21:17:57
Compiler MSVC9 (Visual C++ 2008)
Architecture x86
Configure Command cscript /nologo configure.js
"--enable-snapshot-build" "--disable-isapi" "--enable-debug-pack"
"--without-mssql" "--without-pdo-mssql" "--without-pi3web"
"--with-pdo-oci=C:\php-sdk\oracle\instantclient10\sdk,shared"
"--with-oci8=C:\php-sdk\oracle\instantclient10\sdk,shared"
"--with-oci8-11g=C:\php-sdk\oracle\instantclient11\sdk,shared"
"--enable-object-out-dir=../obj/" "--enable-com-dotnet"
"--with-mcrypt=static" "--disable-static-analyze" "--with-pgo"
Server API Apache 2.4 Handler Apache Lounge
Virtual Directory Support enabled
Configuration File (php.ini) Path C:\Windows

....

mysqlnd
mysqlnd enabled
Version mysqlnd 5.0.10 - 20111026 - $Id:
b0b3b15c693b7f6aeb3aa66b646fee339f175e39 $
Compression supported
SSL supported

But if I now try to connect to the database, pypmyadmin tells me, that
mysql can't be found: Cannot load mysql extension.

My one site tells me the same:
Fatal error: Call to undefined function mysql_error() in...

netstat tells me, that mysql is waiting on 3306.

Can someone gives me a hint?

Thank you from Switzerland, Markus
Re: cant use mysql_connect [message #179435 is a reply to message #179434] Sun, 28 October 2012 16:44 Go to previous messageGo to next message
J.O. Aho is currently offline  J.O. Aho
Messages: 194
Registered: September 2010
Karma: 0
Senior Member
Markus Grob wrote:
> Hello together
>
> I have changed to Apache 2.4 with PHP 5.4 and MySQL 5.5. MySQL is running and
> all databases were imported from the earlier version.
> Apache is running and php_info gives me the hint, that mysqlnd was found:
>
> PHP Version 5.4.4
> System Windows NT KRWM0023 6.1 build 7601 (Windows 7 Enterprise Edition Service Pack 1) i586
> mysqlnd enabled

>
> But if I now try to connect to the database, pypmyadmin tells me, that mysql
> can't be found: Cannot load mysql extension.

phpmyadmin uses the mysql extension, not the mysqlnd, so you need to find a
compiled mysql extension for your version of PHP (usually a lot easier if you
use Linux/BSD as your server OS, for then you generally get everything you
need at once and less risk for backdoors in modules).

--

//Aho
Re: cant use mysql_connect [message #179436 is a reply to message #179434] Sun, 28 October 2012 16:51 Go to previous messageGo to next message
Luuk is currently offline  Luuk
Messages: 329
Registered: September 2010
Karma: 0
Senior Member
On 28-10-2012 17:30, Markus Grob wrote:
> Hello together
>
> I have changed to Apache 2.4 with PHP 5.4 and MySQL 5.5. MySQL is
> running and all databases were imported from the earlier version.
> Apache is running and php_info gives me the hint, that mysqlnd was found:
>
> PHP Version 5.4.4
>
> System Windows NT KRWM0023 6.1 build 7601 (Windows 7 Enterprise
> Edition Service Pack 1) i586
> Build Date Jun 13 2012 21:17:57
> Compiler MSVC9 (Visual C++ 2008)
> Architecture x86
> Configure Command cscript /nologo configure.js
> "--enable-snapshot-build" "--disable-isapi" "--enable-debug-pack"
> "--without-mssql" "--without-pdo-mssql" "--without-pi3web"
> "--with-pdo-oci=C:\php-sdk\oracle\instantclient10\sdk,shared"
> "--with-oci8=C:\php-sdk\oracle\instantclient10\sdk,shared"
> "--with-oci8-11g=C:\php-sdk\oracle\instantclient11\sdk,shared"
> "--enable-object-out-dir=../obj/" "--enable-com-dotnet"
> "--with-mcrypt=static" "--disable-static-analyze" "--with-pgo"
> Server API Apache 2.4 Handler Apache Lounge
> Virtual Directory Support enabled
> Configuration File (php.ini) Path C:\Windows
>
> ...
>
> mysqlnd
> mysqlnd enabled
> Version mysqlnd 5.0.10 - 20111026 - $Id:
> b0b3b15c693b7f6aeb3aa66b646fee339f175e39 $
> Compression supported
> SSL supported
>
> But if I now try to connect to the database, pypmyadmin tells me, that
> mysql can't be found: Cannot load mysql extension.
>
> My one site tells me the same:
> Fatal error: Call to undefined function mysql_error() in...
>
> netstat tells me, that mysql is waiting on 3306.
>
> Can someone gives me a hint?
>
> Thank you from Switzerland, Markus

In your php.ini, there should be a line like this:
extension=mysql.so

or (better) this:
extension=mysqli.so

or this one:
extension=pdo_mysql.so

all depending on how you want to connect to MySQL
Re: cant use mysql_connect [message #179438 is a reply to message #179434] Sun, 28 October 2012 19:21 Go to previous messageGo to next message
Thomas 'PointedEars'  is currently offline  Thomas 'PointedEars'
Messages: 701
Registered: October 2010
Karma: 0
Senior Member
Markus Grob wrote:

> I have changed to Apache 2.4 with PHP 5.4 and MySQL 5.5. MySQL is
> running and all databases were imported from the earlier version.
> Apache is running and php_info gives me the hint, that mysqlnd was found:

You probably mean phpinfo().

> PHP Version 5.4.4
> […]
> mysqlnd
> mysqlnd enabled
> Version mysqlnd 5.0.10 - 20111026 - $Id:
> b0b3b15c693b7f6aeb3aa66b646fee339f175e39 $
> Compression supported
> SSL supported
>
> But if I now try to connect to the database, pypmyadmin tells me, that
> mysql can't be found: Cannot load mysql extension.
>
> My one site tells me the same:
> Fatal error: Call to undefined function mysql_error() in...
>
> netstat tells me, that mysql is waiting on 3306.

The problem is (obviously) not that your MySQL server is not running or not
responding. The problem is (obviously) that PHP's mysqlnd (MySQL Native
Driver) extension does not provide the obsolete, insecure mysql_* functions.
It uses features provided by other MySQL extensions, mysqli or PDO MySQL,
instead.

RTFM: <http://www.php.net/manual/en/mysqlnd.overview.php>


PointedEars
--
When all you know is jQuery, every problem looks $(olvable).
Re: cant use mysql_connect [message #179445 is a reply to message #179435] Mon, 29 October 2012 03:16 Go to previous messageGo to next message
Thomas 'PointedEars'  is currently offline  Thomas 'PointedEars'
Messages: 701
Registered: October 2010
Karma: 0
Senior Member
J.O. Aho wrote:

> Markus Grob wrote:
>> I have changed to Apache 2.4 with PHP 5.4 and MySQL 5.5. MySQL is running
>> and all databases were imported from the earlier version.
>> Apache is running and php_info gives me the hint, that mysqlnd was found:
>>
>> PHP Version 5.4.4
>> System Windows NT KRWM0023 6.1 build 7601 (Windows 7 Enterprise
>> Edition Service Pack 1) i586
>> mysqlnd enabled
>>
>> But if I now try to connect to the database, pypmyadmin tells me, that
>> mysql can't be found: Cannot load mysql extension.
>
> phpmyadmin uses the mysql extension, not the mysqlnd, so you need to find
> a compiled mysql extension for your version of PHP (usually a lot easier
> if you use Linux/BSD as your server OS, for then you generally get
> everything you need at once and less risk for backdoors in modules).

Utter nonsense. phpMyAdmin is fully capable of using the much safer mysqli
extension, which is used by the mysqlnd extension:

<http://wiki.phpmyadmin.net/pma/mysqli>

(Never trust advice given by pseudo-anonymous or address-munging people.)


PointedEars
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee
Re: cant use mysql_connect [message #179446 is a reply to message #179445] Mon, 29 October 2012 06:34 Go to previous messageGo to next message
J.O. Aho is currently offline  J.O. Aho
Messages: 194
Registered: September 2010
Karma: 0
Senior Member
#
Path: textnews.cambrium.nl!feeder2.cambriumusenet.nl!feed.tweaknews.nl!85.12.40.1 30.MISMATCH!xlned.com!feeder1.xlned.com!news.osn.de!diablo2.news.osn.de!fu- berlin.de!uni-berlin.de!individual.net!not-for-mail
From: "J.O. Aho" <user(at)example(dot)net>
Newsgroups: comp.lang.php
Subject: Re: cant use mysql_connect
Date: Mon, 29 Oct 2012 07:34:00 +0100
Lines: 41
Message-ID: <af6maoFlumU1(at)mid(dot)individual(dot)net>
References: <k6jmij$jt1$1(at)dont-email(dot)me> <af55o8FkjmpU1(at)mid(dot)individual(dot)net> <1944408(dot)oD1fHKOdpR(at)PointedEars(dot)de>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: individual.net 27yTMBMO81J99RRMDZZkkg/JYCKalyRnH1PCcYLgMazFBMn3VeTzhCPGM+EgA9Zu5f
Cancel-Lock: sha1:LrjpsjdOvZbvNKXH9am5u2zgxTI=
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121021 Firefox/16.0 SeaMonkey/2.13.1
In-Reply-To: <1944408(dot)oD1fHKOdpR(at)PointedEars(dot)de>
Xref: textnews.cambrium.nl comp.lang.php:138932

Thomas 'PointedEars' Lahn wrote:
> J.O. Aho wrote:
>
>> Markus Grob wrote:
>>> I have changed to Apache 2.4 with PHP 5.4 and MySQL 5.5. MySQL is running
>>> and all databases were imported from the earlier version.
>>> Apache is running and php_info gives me the hint, that mysqlnd was found:
>>>
>>> PHP Version 5.4.4
>>> System Windows NT KRWM0023 6.1 build 7601 (Windows 7 Enterprise
>>> Edition Service Pack 1) i586
>>> mysqlnd enabled
>>>
>>> But if I now try to connect to the database, pypmyadmin tells me, that
>>> mysql can't be found: Cannot load mysql extension.
>>
>> phpmyadmin uses the mysql extension, not the mysqlnd, so you need to find
>> a compiled mysql extension for your version of PHP (usually a lot easier
>> if you use Linux/BSD as your server OS, for then you generally get
>> everything you need at once and less risk for backdoors in modules).
>
> Utter nonsense. phpMyAdmin is fully capable of using the much safer mysqli
> extension, which is used by the mysqlnd extension:

I stand corrected in this matter (haven't used phpmyadmin for years and back
then it didn't support mysqli and it was prone to a lot of security issues,
which it is still), and it's quite unnecessary to make accusations against a
person, no matter how subtitle it is.

But still, the OP will need to install the mysql extension

>>> My one site tells me the same:
>>> Fatal error: Call to undefined function mysql_error() in...

Even if he gets his phpmyadmin to work, his site will not.
Of course he can rewrite it, but I guess he rather gets it up and running now
and not next year.

--

//Aho
Re: cant use mysql_connect [message #179447 is a reply to message #179434] Mon, 29 October 2012 06:39 Go to previous messageGo to next message
J.O. Aho is currently offline  J.O. Aho
Messages: 194
Registered: September 2010
Karma: 0
Senior Member
Markus Grob wrote:
> Hello together
>
> I have changed to Apache 2.4 with PHP 5.4 and MySQL 5.5. MySQL is running and
> all databases were imported from the earlier version.
> Apache is running and php_info gives me the hint, that mysqlnd was found:
>
> PHP Version 5.4.4
> System Windows NT KRWM0023 6.1 build 7601 (Windows 7 Enterprise Edition
>
> But if I now try to connect to the database, pypmyadmin tells me, that mysql
> can't be found: Cannot load mysql extension.
>
> My one site tells me the same:
> Fatal error: Call to undefined function mysql_error() in...
>
> netstat tells me, that mysql is waiting on 3306.
>
> Can someone gives me a hint?

For the phpmyadmin http://www.phpmyadmin.net/documentation :

$cfg['Servers'][$i]['extension'] string
What php MySQL extension to use for the connection. Valid options are:

mysql : The classic MySQL extension.

mysqli : The improved MySQL extension. This extension became available
with PHP 5.0.0 and is the recommended way to connect to a server running MySQL
4.1.x or newer.

For your site, either rewrite it to not use the mysql extension or download it
from a shady website which claims it's build for the PHP version you installed
and hope it hasn't some nasty backdoor (Recommendation would be that you used
a operating system which provides php and all the extensions without requiring
you to go to 3rd party pages).

--

//Aho
Re: cant use mysql_connect [message #179450 is a reply to message #179445] Mon, 29 October 2012 11:24 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
On 29/10/12 03:16, Thomas 'PointedEars' Lahn wrote:
>
>
> (Never trust advice given by pseudo-anonymous or address-munging people.)
>

Well that's both of us fucked then, isn't it?

>
> PointedEars
>
^^^^^^^^^^^^^^^

--
Ineptocracy

(in-ep-toc’-ra-cy) – a system of government where the least capable to
lead are elected by the least capable of producing, and where the
members of society least likely to sustain themselves or succeed, are
rewarded with goods and services paid for by the confiscated wealth of a
diminishing number of producers.
Re: cant use mysql_connect [message #179451 is a reply to message #179446] Mon, 29 October 2012 13:23 Go to previous messageGo to next message
Thomas 'PointedEars'  is currently offline  Thomas 'PointedEars'
Messages: 701
Registered: October 2010
Karma: 0
Senior Member
J.O. Aho wrote:

> Thomas 'PointedEars' Lahn wrote:
>> J.O. Aho wrote:
>>> phpmyadmin uses the mysql extension, not the mysqlnd, so you need to
>>> find a compiled mysql extension for your version of PHP (usually a lot
>>> easier if you use Linux/BSD as your server OS, for then you generally
>>> get everything you need at once and less risk for backdoors in modules).
>>
>> Utter nonsense. phpMyAdmin is fully capable of using the much safer
>> mysqli extension, which is used by the mysqlnd extension:
>
> I stand corrected in this matter (haven't used phpmyadmin for years and
> back then it didn't support mysqli and it was prone to a lot of security
> issues, which it is still), and it's quite unnecessary to make accusations
> against a person, no matter how subtitle it is.

phpMyAdmin has supported mysqli ever since mysqli came about (PHP 5.0,
2004). (That was *8 years* ago.)

< https://github.com/phpmyadmin/history/blob/master/ChangeLogs/ChangeLog-2004>
<http://www.php.net/manual/en/mysqli.overview.php>

> But still, the OP will need to install the mysql extension

No, they will not, and they should not. It is deprecated for a reason.

>>>> My one site tells me the same:
>>>> Fatal error: Call to undefined function mysql_error() in...
>
> Even if he gets his phpmyadmin to work, his site will not.
> Of course he can rewrite it, but I guess he rather gets it up and running
> now and not next year.

FUD. Go away, and take your address-munged nonsense with you.


PointedEars
--
Sometimes, what you learn is wrong. If those wrong ideas are close to the
root of the knowledge tree you build on a particular subject, pruning the
bad branches can sometimes cause the whole tree to collapse.
-- Mike Duffy in cljs, <news:Xns9FB6521286DB8invalidcom(at)94(dot)75(dot)214(dot)39>
Re: cant use mysql_connect [message #179470 is a reply to message #179434] Tue, 30 October 2012 21:58 Go to previous messageGo to next message
Markus Grob is currently offline  Markus Grob
Messages: 9
Registered: September 2011
Karma: 0
Junior Member
Markus Grob wrote:

> But if I now try to connect to the database, pypmyadmin tells me, that
> mysql can't be found: Cannot load mysql extension.

I have read all the postings and now, I don't know, what I should do. I
can rewrite my code, to use the mysqlnd locally, but I don't know, if
normal webservers could use the new code. Will this normally be? How can
I find it out?

The php_mysql.dll and php_mysqli.dll are in the /ext directory and I
have pointed to them in the php.ini:

....
extension_dir = "C:\Program Files (x86)\php\ext"
....
[PHP_MYSQL]
extension=php_mysql.dll
[PHP_MYSQLI]
extension=php_mysqli.dll


What special is, phpinfo tells me, that apache thinks, that the php.ini
is in c:7windows, but this isn't true. It is in the php dir:
C:\Program Files (x86)

Could it be, that the problem is coming from the "Program Files (x86)" path?

Greetings from Switzerland, Markus
Re: cant use mysql_connect [message #179471 is a reply to message #179470] Tue, 30 October 2012 23:18 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 10/30/2012 5:58 PM, Markus Grob wrote:
> Markus Grob wrote:
>
>> But if I now try to connect to the database, pypmyadmin tells me, that
>> mysql can't be found: Cannot load mysql extension.
>
> I have read all the postings and now, I don't know, what I should do. I
> can rewrite my code, to use the mysqlnd locally, but I don't know, if
> normal webservers could use the new code. Will this normally be? How can
> I find it out?
>
> The php_mysql.dll and php_mysqli.dll are in the /ext directory and I
> have pointed to them in the php.ini:
>
> ...
> extension_dir = "C:\Program Files (x86)\php\ext"
> ...
> [PHP_MYSQL]
> extension=php_mysql.dll
> [PHP_MYSQLI]
> extension=php_mysqli.dll
>
>
> What special is, phpinfo tells me, that apache thinks, that the php.ini
> is in c:7windows, but this isn't true. It is in the php dir:
> C:\Program Files (x86)
>
> Could it be, that the problem is coming from the "Program Files (x86)"
> path?
>
> Greetings from Switzerland, Markus

It sounds like you're not using the php.ini file you think you're using.
phpinfo() shows the one that's actually being used; if that file
doesn't exist, PHP will use a default php.ini file. You need to put
your php.ini file where phpinfo() says it should be (or you could modify
the Windows registry to change the location to wherever you want, but I
recommend the former).

Pretty much all hosts support mysql and mysqli drivers; not everyone
supports mysqlnd. You have a choice of using mysql, which will still be
supported for some time. Or, if you're going to rewrite your code, I
recommend you use the mysqli driver.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: cant use mysql_connect [message #179472 is a reply to message #179470] Wed, 31 October 2012 09:07 Go to previous messageGo to next message
M. Strobel is currently offline  M. Strobel
Messages: 386
Registered: December 2011
Karma: 0
Senior Member
Am 30.10.2012 22:58, schrieb Markus Grob:
> Markus Grob wrote:
>
>> But if I now try to connect to the database, pypmyadmin tells me, that
>> mysql can't be found: Cannot load mysql extension.
>
> I have read all the postings and now, I don't know, what I should do. I can rewrite
> my code, to use the mysqlnd locally, but I don't know, if normal webservers could use
> the new code. Will this normally be? How can I find it out?
>

Trying to sum up the driver thing, see
http://www.php.net/manual/en/mysqli.overview.php

* mysql is an old driver and old API, not recommended
* mysqli is the newer API, with the same design as mysql. Can use mysqlnd
* PDO is the unified and object oriented API. Can use mysqlnd, recommended
* mysqlnd is not an API, only a driver lib

So your programmer's choice is between mysqli and PDO. A webspace provider only
offering the mysql API should not exist anymore.
Re: cant use mysql_connect [message #179473 is a reply to message #179472] Wed, 31 October 2012 09:15 Go to previous messageGo to next message
M. Strobel is currently offline  M. Strobel
Messages: 386
Registered: December 2011
Karma: 0
Senior Member
Am 31.10.2012 10:07, schrieb M. Strobel:
> Am 30.10.2012 22:58, schrieb Markus Grob:
>> Markus Grob wrote:
>>
>>> But if I now try to connect to the database, pypmyadmin tells me, that
>>> mysql can't be found: Cannot load mysql extension.
>>
>> I have read all the postings and now, I don't know, what I should do. I can rewrite
>> my code, to use the mysqlnd locally, but I don't know, if normal webservers could use
>> the new code. Will this normally be? How can I find it out?
>>
>
> Trying to sum up the driver thing, see
> http://www.php.net/manual/en/mysqli.overview.php
>
> * mysql is an old driver and old API, not recommended
> * mysqli is the newer API, with the same design as mysql. Can use mysqlnd
> * PDO is the unified and object oriented API. Can use mysqlnd, recommended
> * mysqlnd is not an API, only a driver lib
>
> So your programmer's choice is between mysqli and PDO. A webspace provider only
> offering the mysql API should not exist anymore.
>
Addition: changing the interface from mysql to mysqli is normally only a matter of
adding the i ...

/Str.
Re: cant use mysql_connect [message #179476 is a reply to message #179470] Wed, 31 October 2012 23:56 Go to previous message
Thomas 'PointedEars'  is currently offline  Thomas 'PointedEars'
Messages: 701
Registered: October 2010
Karma: 0
Senior Member
Markus Grob wrote:

> Markus Grob wrote:
>> But if I now try to connect to the database, pypmyadmin tells me, that
>> mysql can't be found: Cannot load mysql extension.
>
> I have read all the postings and now, I don't know, what I should do. I
> can rewrite my code, to use the mysqlnd locally, but I don't know, if
> normal webservers could use the new code. Will this normally be? How can
> I find it out?

The extensions need to be loaded. phpinfo() can tell.

> The php_mysql.dll and php_mysqli.dll are in the /ext directory and I
> have pointed to them in the php.ini:
>
> ...
> extension_dir = "C:\Program Files (x86)\php\ext"
> ...
> [PHP_MYSQL]
> extension=php_mysql.dll
> [PHP_MYSQLI]
> extension=php_mysqli.dll

The sections are optional (AFAIK), the `extension' directives are not.

> What special is, phpinfo tells me, that apache thinks, that the php.ini
> is in c:7windows, but this isn't true. It is in the php dir:
> C:\Program Files (x86)

Does phpinfo() say that the two extensions are loaded? (Are there any
occurrences of `mysql' or `mysqli' headings in the output?)

Are you sure there is only one php.ini? It matters not if you write your
directives into an .ini file that is not considered by PHP in the first
place.

> Could it be, that the problem is coming from the "Program Files (x86)"
> path?

Yes. Look in the phpinfo() output where it says where the .ini files are
and modify *those* files. As an alternative, you can set the PHPDIR system
environment variable to your real PHP directory, then restart Apache. (This
has worked for me with the PHP ISAPI module on Windows. It might also work
with Apache on Windows.)

I am afraid your English is not so good, therefore not well readable and
understandable; it is obviously based on German sentence structure (I can
tell). Why do you not post to de.comp.lang.php instead?


PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f806at$ail$1$8300dec7(at)news(dot)demon(dot)co(dot)uk>
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: skipping question "Do you want to save or open the file"
Next Topic: PDO_SQLITE == sqlite3 ?
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Nov 23 08:44:21 GMT 2024

Total time taken to generate the page: 0.02594 seconds