Click here to Skip to main content
14,643,391 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hi everyone,

I'm currently working on a website that you log into, and it needs a changing username part of it.

My update query seems to be ok, but my php is not:

<?php

$con = mysql_connect("~-~-~-~","~-~-~-~","~-~-~-~");

if (!$con){
    die('Could not connect: ' . mysql_error());
}

mysql_select_db("~-~-~-~", $con);

$username_update = mysql_query("UPDATE users SET username='" . $_GET['confirm_username'] . "' WHERE username='$my_username'");

$username_select = mysql_query("SELECT username FROM users WHERE username = '" . $_GET['confirm_username'] . "'");

$row = mysql_fetch_array($username_select);

if (!$row = $my_username){
    ?>
        <div id="username_changed_green">
            Username Changed
        </div>
    <?php
}else{
    ?>
        <div id="incorrect_details_username">
            Incorrect Details
        </div>
    <?php
}
mysql_close($con);
?>


On the website when it is live, the incorrect details box just shows, any suggestions?

Regards,
Tom.
Posted
Comments
solutions@ashish 21-Mar-12 9:11am
   
Where is the form, and where is the form method to post or get myusername value,
Can you please describe the place by where you get confirm username value "$_GET['confirm_username']"

If You write only this code which you have shared with us, then I want to say that this code is uncompleted

Please share complete code
Rate this:
Please Sign up or sign in to vote.

Solution 1

if (!$row = $my_username){

Are you trying to assign here, or should you be testing for equality? ;o)

Danny
   
v2
Rate this:
Please Sign up or sign in to vote.

Solution 2

Change
if (!$row = $my_username){

to
if ($row['username'] != $my_username){


Thanks

Anand Ayyappan
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month



CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100