“Premature end of data” error with PHP

前端 未结 4 1145
无人共我
无人共我 2020-12-06 07:29

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\",\"mypa         


        
4条回答
  •  难免孤独
    2020-12-06 07:45

    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;
    

提交回复
热议问题