Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Page 4 of 5 FirstFirst 12345 LastLast
Results 31 to 40 of 49
  1. #31
    Join Date
    Oct 2008
    Posts
    43
    Tokens
    0

    Default

    Hey,

    Can't tell if this was ever fixed. So will post a quick solution. When echoing/setting a variable to text inside double quotes you can easily add in variables by simply using {$myvar} directly in the text.
    The errors are most likely due to a missing character escape. A solution to that would be make use of a more advanced method of creating a string. Rather than double quotes use:

    Code:
    ecgo <<<EOF
    
    text you 'want' "here"
    
    EOF;
    The advantage of EOF tags is you don't have to worry about escaping any quotation marks

    Finally the problem with your mysql is that your using the syntax to add a new row. Not to update one
    Update syntax should be as follows
    Code:
    UPDATE table_name SET column1=value, column2=value2 WHERE some_column=some_value
    assuming you are updating an existing row. If you trying to create a new row though, your syntax is correct, but you should be using the command "INSERT INTO" rather than UPDATE.

    Hope that helps.
    CS-Dude
    Last edited by CS-dude; 17-11-2008 at 06:04 AM.

  2. #32
    Join Date
    Dec 2006
    Posts
    3,970
    Tokens
    0

    Latest Awards:

    Default

    Just put {} around the var so it would be like {$database['username']}
    Lets set the stage on fire, and hollywood will be jealous.

  3. #33
    Join Date
    Oct 2006
    Location
    Peterborough, UK
    Posts
    3,855
    Tokens
    216

    Latest Awards:

    Default

    Quote Originally Posted by CS-dude View Post
    Hey,

    Can't tell if this was ever fixed. So will post a quick solution. When echoing/setting a variable to text inside double quotes you can easily add in variables by simply using {$myvar} directly in the text.
    The errors are most likely due to a missing character escape. A solution to that would be make use of a more advanced method of creating a string. Rather than double quotes use:

    Code:
    ecgo <<<EOF
    
    text you 'want' "here"
    
    EOF;
    The advantage of EOF tags is you don't have to worry about escaping any quotation marks

    Finally the problem with your mysql is that your using the syntax to add a new row. Not to update one
    Update syntax should be as follows
    Code:
    UPDATE table_name SET column1=value, column2=value2 WHERE some_column=some_value
    assuming you are updating an existing row. If you trying to create a new row though, your syntax is correct, but you should be using the command "INSERT INTO" rather than UPDATE.

    Hope that helps.
    CS-Dude
    They're called HEREDOC tags and can be anything, i.e

    PHP Code:
    $what = <<<HELLO

    HELLO;

    $what = <<<HURFDURF

    HURFDURF; 
    The only thing that you need to know is that the HELLO; part must be at the very start of the line, there can't be anything in front of it.


    visit my internet web site on the internet
    http://dong.engineer/
    it is just videos by bill wurtz videos you have been warned

  4. #34
    Join Date
    Jul 2008
    Posts
    535
    Tokens
    75

    Default

    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' nickname=, location=, email=, gender=, bio=, favouritemovie=, favouritemusic=, ' at line 1

    PHP Code:
        mysql_query("INSERT INTO users SET firstname={$fname}, lastname={$lname}, nickname={$nname}, location={$location}, email={$email}, gender={$gender}, bio={$bio}, favouritemovie={$fmovies}, favouritemusic={$fmusic}, favouritebooks={$fbooks} WHERE username={$grab_username}") or die(mysql_error()); 

  5. #35
    Join Date
    Mar 2008
    Posts
    5,108
    Tokens
    3,780

    Latest Awards:

    Default

    no dude.. for INSERT you use:

    INSERT INTO `bla` (`ha`, `ha`) VALUES('$variable', '$bal')

    for UPDATE:

    UPDATE `bla` SET `field`='$value', `bla`='$bla'

  6. #36
    Join Date
    Jul 2008
    Posts
    535
    Tokens
    75

    Default

    oh, forgot to change it to update. however once I changed it to update I still get the error.

  7. #37
    Join Date
    Mar 2008
    Posts
    5,108
    Tokens
    3,780

    Latest Awards:

    Default

    because you need to do.. `field`='$value'

    you don't need {}'s and you need to have ''s around the value..

  8. #38
    Join Date
    Jul 2008
    Posts
    535
    Tokens
    75

    Default

    PHP Code:
        mysql_query("UPDATE `users` SET `firstname`='$fname', `lastname`='$lname', `nickname`='$nname', `location`='$location', `email`='$email', `gender`='$gender', `bio`='$bio', `favouritemovie`='$fmovies', `favouritemusic`='$fmusic', `favouritebooks`='$fbooks' WHERE `username`='$grab_username'") or die(mysql_error()); 
    Thanks for that, it got rid of the error. I know I'm a complete noob at PHP but hopefully I'll improve. Anyway, that code doesn't update the database.

  9. #39
    Join Date
    Mar 2008
    Posts
    5,108
    Tokens
    3,780

    Latest Awards:

    Default

    Are you sure the query is actually being executed? Post your full code.

  10. #40
    Join Date
    Jul 2008
    Posts
    535
    Tokens
    75

    Default

    PHP Code:
    <?php 

    $fname 
    $_POST['firstname'];
    $lname $_POST['lastname'];
    $nname $_POST['nickname'];
    $location $_POST['location'];
    $email $_POST['email'];
    $gender $_POST['gender'];
    $bio $_POST['bio'];
    $fmovies $_POST['favmovies'];
    $fmusic $_POST['favmusic'];
    $fbooks $_POST['favbooks'];
        
    $fname htmlspecialchars($fname);
    $lname htmlspecialchars($lname);
    $nname htmlspecialchars($nname);
    $location htmlspecialchars($location);
    $email htmlspecialchars($email);
    $gender htmlspecialchars($gender);
    $bio htmlspecialchars($bio);
    $fmovies htmlspecialchars($fmovies);
    $fmusic htmlspecialchars($fmusic);
    $fbook htmlspecialchars($fbooks);

    $currentpassword mysql_query("SELECT `password` FROM `users` WHERE `username` = '$grab_username'");
    $newpassword $_POST['newpassword'];
    $newpassword md5($newpassword);

    $query mysql_query("SELECT * FROM `users` WHERE `username` = '$grab_username'");
    $value mysql_fetch_array($query);

    if(
    $_GET['do'] == update){
        
    mysql_query("UPDATE `users` SET `firstname`='$fname', `lastname`='$lname', `nickname`='$nname', `location`='$location', `email`='$email', `gender`='$gender', `bio`='$bio', `favouritemovie`='$fmovies', `favouritemusic`='$fmusic', `favouritebooks`='$fbooks' WHERE `username`='$grab_username'") or die(mysql_error());

        echo 
    "congrats, you have updated your info.";
        echo 
    "<meta HTTP-EQUIV=\"refresh\" CONTENT=\"5\"; URL=\"index.php\">";


    if(
    $_GET['do'] == updatepw){
        if(
    $currentpassword != $value['password']){
            echo 
    "sorry, but the password you entered does not match your current one.";
        } else {
            
    mysql_query("UPDATE `users` WHERE `password` = '$newpassword'");
            echo 
    "congrats, you have updated your password.";
            echo 
    "<meta HTTP-EQUIV=\"refresh\" CONTENT=\"5\"; URL=\"index.php\">";
        }
    }
    else {
    ?>

    <form action="?do=update" method="post">
    first name: <input type="text" name="firstname" value="<?php echo $value['firstname'?>" /><br />
    last name: <input type="text" name="lastname" value="<?php echo $value['lastname'?>" /><br />
    nick name: <input type="text" name="nickname" value="<?php echo $value['nickname'?>" /><br />
    location: <input type="text" name="location" value="<?php echo $value['location'?>" /><br />
    email: <input type="text" name="email" value="<?php echo $value['email'?>" /><br />
    gender: <input type="radio" name="gender" value="male" /> male <input type="radio" name="gender" value="female" /> female<br />
    bio: <input type="text" height="200px" width="300px" name="bio" value="<?php echo $value['bio'?>" /><br />
    fav movies: <input type="text" height="200px" width="300px" name="favmovies" value="<?php echo $value['favmovies'?>" /><br />
    fav music: <input type="text" height="200px" width="300px" name="favmusic" value="<?php echo $value['favmusic'?>" /><br />
    fav books: <input type="text" height="200px" width="300px" name="favbooks" value="<?php echo $value['favbooks'?>" /><br />
    <input type="submit" value="update profile" />
    </form><br />
    <br />
    want to change your password?
    <form action="?do=updatepw" method="post">
    current password: <input type="password" name="currentpassword" /><br />
    new password: <input type="password" name="newpassword" /><br />
    <input type="submit" value="update password" />
    </form>

    <?php
    }
    ?>
    The config include, session_start and ob_start are all at the top of the page, so they're not in that code.

Page 4 of 5 FirstFirst 12345 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •