You are not logged in.

#1 2009-11-29 18:21:06

nighthawk
Member
Registered: 2009-11-29
Posts: 20

PHP 5.3.1 & Mysql problem

Ive been looking arround the internet for 2days trying to find the solutions looked on arch's wiki page didnt find a solution so decided to come ask here

everytime i run a script with mysql in it i get

PHP Warning:  mysql_connect(): OK packet 6 bytes shorter than expected in /srv/http/index.php on line 5
PHP Warning:  mysql_connect(): mysqlnd cannot connect to MySQL 4.1+ using old authentication in /srv/http/index.php on line 5
PHP Warning:  mysql_select_db(): [2002] No such file or directory (trying to connect via unix:///var/run/mysqld/mysqld.sock) in /srv/http/index.php on line 6

any help would be helpful smile

Offline

#2 2009-11-29 18:36:41

ralvez
Member
From: Canada
Registered: 2005-12-06
Posts: 1,694
Website

Re: PHP 5.3.1 & Mysql problem

Well ... for one thing you should try to use mysqli. To do so, you just uncomment the mysqli line in the configuration file.
Also, it would be helpful to know what is the lines 5 and 6 (the ones the complaints are about), perhaps that could give us a clue.


R.

Offline

#3 2009-11-29 18:38:46

nighthawk
Member
Registered: 2009-11-29
Posts: 20

Re: PHP 5.3.1 & Mysql problem

line 5 and 6 are:

mysql_connect($server,$name,$pass);
mysql_select_db($name);

and mysqli gives exact same error ive tried that.

Offline

#4 2009-11-30 03:28:10

ralvez
Member
From: Canada
Registered: 2005-12-06
Posts: 1,694
Website

Re: PHP 5.3.1 & Mysql problem

What I meant is that you should be using mysqli, not that it is a good idea only  wink
If you take a look at this: http://php.net/manual/en/function.mysql-select-db.php you will see why is not working... a reference to the established connection is missing.

Hope this helps.

R,

Offline

#5 2009-11-30 03:45:48

nighthawk
Member
Registered: 2009-11-29
Posts: 20

Re: PHP 5.3.1 & Mysql problem

That didnt help :\ that doesn't have anything to do with it, now when i try with php-5.2.9 it works fine but php-5.3.11 gives this error its nothing to do with how im doing the connection and that proves it.

Offline

#6 2009-11-30 12:50:31

ralvez
Member
From: Canada
Registered: 2005-12-06
Posts: 1,694
Website

Re: PHP 5.3.1 & Mysql problem

I always follow the rules of the language I'm using; so the "style" that PHP calls for (look the link I sent you) is :

// open a connection to a DB
$myconn = openconnection();
mysql_select_db($myconn['db'],$myconn['link']);

and with all due respect the fact that works somewhere else is not proof of correctness ... I have seen bad code working and good code not working before for different reasons.

My suggestion at this point is that you install xdebug (it's actually very easy) and use it to find what's wrong.

R.

Offline

#7 2009-11-30 14:46:22

nighthawk
Member
Registered: 2009-11-29
Posts: 20

Re: PHP 5.3.1 & Mysql problem

ralvez, i found out that local host connections work but when i try to connect to my webserver from my pcp it doesnt the server uses mysql 5.0.85 if that is any help.

Offline

#8 2009-11-30 16:04:51

o_O-
Member
Registered: 2009-11-30
Posts: 2

Re: PHP 5.3.1 & Mysql problem

1) There is no point in preferring mysqli over mysql if you don't need any of its added complexity. If you don't need it, it doesn't bring any extra value either. PDO does add extra value without introducing much complexity, and is worth the recommendation.

2) This is not a PHP error, hence, it is of no use to look into the documentation of PHP functions. RTFM.

See http://dev.mysql.com/doc/refman/5.1/en/old-client.html

So far I can conclude that at least the mysql and mysqli PHP extensions have been linked to an ancient version of the mysql client libraries. Please post the relevant sections (mysql and mysqli extensions) of the output of phpinfo below.

See http://php.net/phpinfo

Offline

#9 2009-11-30 16:15:49

nighthawk
Member
Registered: 2009-11-29
Posts: 20

Re: PHP 5.3.1 & Mysql problem

mysqlnd
mysqlnd    enabled
Version     mysqlnd 5.0.5-dev - 081106 - $Revision: 289630 $
Command buffer size     4096
Read buffer size     32768
Read timeout     31536000
Collecting statistics     Yes
Collecting memory statistics     No

Offline

#10 2009-11-30 16:24:03

o_O-
Member
Registered: 2009-11-30
Posts: 2

Re: PHP 5.3.1 & Mysql problem

It appears that you are using the native driver shipped with PHP 5.3+. The native driver only works with MySQL server 4.1+ using the new authentication algorithm and new password style.

Maybe the server you are connecting to still has an old-fashioned password for your account. The solution could be to update your password to use the new style, see:
http://rabaix.net/en/articles/2009/09/2 … tion-issue

See http://dev.mysql.com/doc/refman/5.1/en/ … shing.html for more information on password hashing in MySQL server and how it changed in 4.1.
Best (second) bet is to recompile PHP using MySQL client libraries rather than mysqlnd (this should be the default though). In fact, mysqlnd claims to be complete but lacks essential compatibility features even for 4.1+ servers. There is no point in using mysqlnd as it is a third-party ad-hoc replacement for libmysqlclient. The latter will always be more up to date than anything else, because it is developed together with MySQL server.

Last edited by o_O- (2009-11-30 16:25:06)

Offline

#11 2009-11-30 17:33:46

nighthawk
Member
Registered: 2009-11-29
Posts: 20

Re: PHP 5.3.1 & Mysql problem

That fixed it big_smile thanks

Offline

Board footer

Powered by FluxBB