Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

cant update my mysql database using php

  • 02-04-2004 05:26PM
    #1
    Banned (with Prison Access) Posts: 13,016 ✭✭✭✭


    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,016 ✭✭✭✭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, Registered Users 2 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, Registered Users 2 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