"数据&QUOT的premature结束;错误使用PHP [英] "Premature end of data" error with PHP

查看:210
本文介绍了"数据&QUOT的premature结束;错误使用PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用WAMP的PHP项目刚刚开始,我得到这个行code相关的下一个错误:

  $链接= mysql_connect(localhost,则为myuser,mypas);

我看了,我不得不与我的旧密码再做一次设置密码,但它仍然没有重新启动所有服务后工作。我使用PHP 5.3.4和MySQL 53年1月5日任何帮助吗?谢谢

 警告:mysql_connect()函数[function.mysql连接]:在C:数据(554 mysqlnd_wireprotocol.c)的premature结束\\ WAMP \\ WWW \\ CDE \\包括\\ baseDatos.php第5行
调用堆栈
1 0.0002 667312 {}主().. \\的index.php:0
2 0.0008 682416包括('C:\\ WAMP \\ WWW \\ CDE \\包括\\ seguridad.php').. \\的index.php:2
3 0.0010 690984包括('C:\\ WAMP \\ WWW \\ CDE \\包括\\ baseDatos.php').. \\ seguridad.php:2
4 0.0014 692368 mysql_connect()函数.. \\ baseDatos.php:5警告(!):mysql_connect()函数[function.mysql连接]:用C比预期OK包1个字节短:\\ WAMP \\ WWW \\ CDE \\包括第5行\\ baseDatos.php
调用堆栈
1 0.0002 667312 {}主().. \\的index.php:0
2 0.0008 682416包括('C:\\ WAMP \\ WWW \\ CDE \\包括\\ seguridad.php').. \\的index.php:2
3 0.0010 690984包括('C:\\ WAMP \\ WWW \\ CDE \\包括\\ baseDatos.php').. \\ seguridad.php:2
4 0.0014 692368 mysql_connect()函数.. \\ baseDatos.php:5警告(!):mysql_connect()函数[function.mysql连接]:mysqlnd可以使用旧的不安全的验证无法连接到MySQL 4.1+。请使用管理工具来使用命令SET PASSWORD = PASSWORD('your_existing_password')重置您的密码。这将存储在mysql.user一个新的,更安全,散列值。如果该用户是由PHP 5.2执行的其他脚本中使用或更早版本则可能需要从my.cnf文件删除旧密码标志在C:\\ WAMP \\ WWW \\ CDE \\包括\\ baseDatos.php第5行
调用堆栈
1 0.0002 667312 {}主().. \\的index.php:0
2 0.0008 682416包括('C:\\ WAMP \\ WWW \\ CDE \\包括\\ seguridad.php').. \\的index.php:2
3 0.0010 690984包括('C:\\ WAMP \\ WWW \\ CDE \\包括\\ baseDatos.php').. \\ seguridad.php:2
4 0.0014 692368 mysql_connect()函数.. \\ baseDatos.php:5


解决方案

我有同样的问题,并固定它使用UPDATE查询是这样的:

 更新mysql.user设置密码= PASSWORD('NEWPWD')其中host ='some_host'和User ='some_user';

不知道为什么,但设定的密码没有奏效。

要确保问题是一个我认为你应该做的mysql数据库在这个查询:

  SELECT
`user`.`Password`

`user`
哪里
`user`.`User` ='youruser'AND
`user`.`Host` ='yourhost'

如果密码不以启动*问题是,你仍然有旧encription

编辑_这里是一个PHP函数来创建MYSQL有效的密码(从这里采取):

 (以$)函数mysql_41_password
{
$ P = SHA1($的,真正的);
$ P = SHA1($ P);
回归*strtoupper($ P)。
}

Thene可以手动设置的密码:

  // NEWPWD是passowr在PHP dgenerated
更新mysql.user设置密码='NEWPWD'其中host ='some_host'和User ='some_user';
FLUSH PRIVILEGES;

I've just started using WAMP for a PHP project and I get the next errors related with this line of code:

$link=mysql_connect("localhost","myuser","mypas");

I read that I had to do the SET PASSWORD again with my old password, but it still does not work after restarting all services. I am using PHP 5.3.4 and MySQL 5.1.53 Any help? THANKS

Warning: mysql_connect() [function.mysql-connect]: Premature end of data (mysqlnd_wireprotocol.c:554) in C:\wamp\www\CDE\includes\baseDatos.php on line 5 
Call Stack 
1 0.0002 667312 {main}( ) ..\index.php:0 
2 0.0008 682416 include( 'C:\wamp\www\CDE\includes\seguridad.php' ) ..\index.php:2 
3 0.0010 690984 include( 'C:\wamp\www\CDE\includes\baseDatos.php' ) ..\seguridad.php:2 
4 0.0014 692368 mysql_connect ( ) ..\baseDatos.php:5 

( ! ) Warning: mysql_connect() [function.mysql-connect]: OK packet 1 bytes shorter than expected in C:\wamp\www\CDE\includes\baseDatos.php on line 5 
Call Stack 
1 0.0002 667312 {main}( ) ..\index.php:0 
2 0.0008 682416 include( 'C:\wamp\www\CDE\includes\seguridad.php' ) ..\index.php:2 
3 0.0010 690984 include( 'C:\wamp\www\CDE\includes\baseDatos.php' ) ..\seguridad.php:2 
4 0.0014 692368 mysql_connect ( ) ..\baseDatos.php:5 

( ! ) Warning: mysql_connect() [function.mysql-connect]: mysqlnd cannot connect to MySQL 4.1+ using the old insecure authentication. Please use an administration tool to reset your password with the command SET PASSWORD = PASSWORD('your_existing_password'). This will store a new, and more secure, hash value in mysql.user. If this user is used in other scripts executed by PHP 5.2 or earlier you might need to remove the old-passwords flag from your my.cnf file in C:\wamp\www\CDE\includes\baseDatos.php on line 5 
Call Stack 
1 0.0002 667312 {main}( ) ..\index.php:0 
2 0.0008 682416 include( 'C:\wamp\www\CDE\includes\seguridad.php' ) ..\index.php:2 
3 0.0010 690984 include( 'C:\wamp\www\CDE\includes\baseDatos.php' ) ..\seguridad.php:2 
4 0.0014 692368 mysql_connect ( ) ..\baseDatos.php:5 

解决方案

I had the same problem and fixed it using an UPDATE query like this:

UPDATE mysql.user SET Password = PASSWORD('newpwd') WHERE Host = 'some_host' AND User = 'some_user';

Don't know why but SET Password didn't work.

To be sure that the problem is the one i think you should do this query on the mysql database:

SELECT
`user`.`Password`
FROM
`user`
WHERE
`user`.`User` = 'youruser' AND
`user`.`Host` = 'yourhost'

if the password doesn't start with a * the problem is that you still have the old encription

EDIT _ Here is a php function to create valid password for MYSQL (taken from here):

function mysql_41_password($in)
{
$p=sha1($in,true);
$p=sha1($p);
return "*".strtoupper($p);
}

Thene you can set the password manually:

//newpwd is the passowr dgenerated in php
UPDATE mysql.user SET Password = 'newpwd' WHERE Host = 'some_host' AND User = 'some_user';
FLUSH PRIVILEGES;

这篇关于"数据&QUOT的premature结束;错误使用PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆