Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

cant update my mysql database using php

Options
  • 02-04-2004 5:26pm
    #1
    Banned (with Prison Access) Posts: 13,018 ✭✭✭✭


    ok im on a linux redhat 9 box and am building an interface using php as the front end and mysql as the database

    going ok so far but im after reaching a big stumbling block
    users in my project can register and login grand
    but for some reason i cant for the life of me update any info in the database
    ie UPDATES wont work for me
    i have come to the conclusion that there is some privilage i have to invoke but where and what(especially when inserts work from php and mysql but updates wont)
    i can manually do updates from the mysql console but cant from a script

    ill post some code to make it clearer

    [PHP]//if all is ok then we can insert new password into our Mysql database

    $query=("UPDATE names SET password = Password($newpassword) WHERE password =Password($oldpassword) AND username = $username ;");

    $result = mysql_query($query);
    if(!$result)
    {
    echo"Could not register you in the database please try again later!!</br>";
    echo"Database must be down";
    echo"The query is$query</br>";
    echo"The result is$result</br>";


    }

    else
    {

    echo "your new password is now set to $password";
    }[/PHP]

    name of my table is names and the field i wnat to update within that table is password
    is there a conflict there!? the variable being passed is password too

    when i do a echo query i get

    UPDATE names SET password = Password(abc) WHERE password =Password(uniquekey) AND username = myname ;

    echo result gives me nothing

    anyideas!?:confused:


Comments

  • Banned (with Prison Access) Posts: 16,659 ✭✭✭✭dahamsta


    Non-numeric strings need to be quoted, so put single quotes around '$username'. You can drop the semicolon off the end too, that's handled internally by PHP. Have a look at mysql_error() while you're at it.

    adam


  • Banned (with Prison Access) Posts: 13,018 ✭✭✭✭jank


    nah that doesnt work and if i try to impliement the mysql_error()

    like mysql_error($query)

    Warning: mysql_error(): supplied argument is not a valid MySQL-Link resource in "file/path/of/page.htm

    but ill look into it


  • Registered Users Posts: 927 ✭✭✭decob


    Well for pricileges do something like this...

    mysql> GRANT ALL PRIVILEGES ON *.* TO blah@localhost
    IDENTIFIED BY 'some_password' WITH GRANT OPTION;
    mysql> GRANT ALL PRIVILEGES ON *.* TO blah@"%"
    IDENTIFIED BY 'some_password' WITH GRANT OPTION;

    where blah is the username your using in your mysql_connect and some_password obviously the password


    Also is the username in the table a unique value?

    and try something like
    [php]
    if(!$result)
    {
    echo("DB Error: " . mysql_errno() . " " . mysql_error());
    }
    [/php]


  • Registered Users Posts: 236 ✭✭richardo


    $query=("UPDATE names SET password = Password($newpassword) WHERE password =Password($oldpassword) AND username = $username ;");

    Try:
    $query=("UPDATE names SET password = '$newpassword' WHERE password ='$oldpassword' AND username = '$username'");


Advertisement