You are not logged in.
Pages: 1
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
Offline
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
line 5 and 6 are:
mysql_connect($server,$name,$pass);
mysql_select_db($name);
and mysqli gives exact same error ive tried that.
Offline
What I meant is that you should be using mysqli, not that it is a good idea only
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
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
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
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
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.
Offline
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
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
That fixed it thanks
Offline
Pages: 1