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 1 of 4 1234 LastLast
Results 1 to 10 of 35
  1. #1
    Join Date
    Dec 2007
    Location
    Toronto, Ontario, Canada
    Posts
    689
    Tokens
    0

    Default mySQL Not Updating?

    I have the following PHP code, instead of updating the mySQL as it should, it just clears the contents that should be updating.

    PHP Code:
    <?php

    include( "site_config.php" );
    if( 
    $_GET["action"] == "update_settings" )
    {
        
    $title $_POST["title"];
        
    $status $_POST["status"];
        
    $logo $_POST["main_logo"];
        
    $offline $_POST["offline"];
        
    $left $_POST["left_logo"];
        @
    mysql_query"UPDATE `settings` SET `title` = '$title', `main_logo` = '$logo', `offline_text` = '$offline', `status` = '$status', `logo_left` = '$left'" );
    }
    else 
    {
        
    $fetch = @mysql_fetch_arraymysql_query"SELECT * FROM `settings`" ) );
        
    $title $fetch["title"];
        
    $status $fetch["statust"];
        
    $logo $fetch["main_logo"];
        
    $offline $fetch["offline_text"];
        
    $left_logo $fetch["logo_left"];
    }

    $html = <<<HTML
    <form action="?action=update_settings" method="post"> 
    <h2>site title - <span>this is the title your browser displays for your website.</span></h2><br /> 
    <input class="textbox" name="title" type="text" value="
    $title"/> 

    <h2>site status - <span>this declares whther your site is online or offline.</span></h2><br /> 
    <input name="status" type="radio" value="offline">Offline</input>&nbsp;<input name="status" type="radio" value="online">Online</input> 

    <h2>offline notice - <span>this is the message users see when the website is set to offline.</span></h2> 
    <textarea class="textarea" name="offline" type="text">
    $offline</textarea> 

    <h2>main logo - <span>this is your sites main logo.</span></h2> 
    <input class="textbox" name="main_logo" type="text" value="
    $logo"/> 

    <h2>semi-main logo - <span>this is your sites semi-main logo. its the bigger logo seen on the left of each page.</span></h2><br /> 
    <input class="textbox" name="left_logo" type="text" value="
    $left_logo"/> 

    <br /><br /> 

    <input type="submit" value="edit settings"  class="submit" /> 
    </form> 
    HTML;


        echo( 
    $html );


    ?>
    +rep to all help, whether it works or not.

  2. #2
    Join Date
    May 2005
    Location
    San Francisco, CA
    Posts
    7,160
    Tokens
    2,331

    Latest Awards:

    Default

    You're using the name attribute for your inputs. Try using the id attribute.

  3. #3
    Join Date
    Mar 2008
    Posts
    173
    Tokens
    0

    Default

    Quote Originally Posted by Invent View Post
    You're using the name attribute for your inputs. Try using the id attribute.
    That is how you do it though, the name.

  4. #4
    Join Date
    Dec 2007
    Location
    Toronto, Ontario, Canada
    Posts
    689
    Tokens
    0

    Default

    No, that doesn't do anything.

  5. #5
    Join Date
    Feb 2007
    Location
    Essex, England
    Posts
    1,392
    Tokens
    0

    Latest Awards:

    Default

    I'm not sure I know what you mean but is it because your just changing it all, you're not specifying which row? Like..

    UPDATE `blah` SET `blah='blah' WHERE `id`='1337'


  6. #6
    Join Date
    Dec 2007
    Location
    Toronto, Ontario, Canada
    Posts
    689
    Tokens
    0

    Default

    That's not the problem - does anybody know? I need this asap.

  7. #7
    Join Date
    Sep 2006
    Location
    Evanston, Illinois.
    Posts
    2,361
    Tokens
    0

    Latest Awards:

    Default

    Never use a @ in development and try and space out queries eg

    $sql = "SELECT * FROM foo";
    $result = mysql_query($sql) or die(mysql_error());
    $row = mysql_fetch_array($result);


    oh and in ur action use <?php echo $_SERVER['PHP_SELF']; ?>?action=update_settings
    Last edited by Hypertext; 08-03-2008 at 05:59 PM.
    How could this hapen to meeeeeeeeeeeeeee?lol.

  8. #8
    Join Date
    Mar 2008
    Posts
    173
    Tokens
    0

    Default

    Why not use an @? That stops the output.

    @imagecreatefromgif($image);

    If image is not defined, it breaks and spits out everything in the world. That just shuts it up.

    It doesn't matter about spacing queries out other then just being able to read them better.

    The PHP_SELF thing doesn't matter one bit.

    You don't need it.



    @Will:

    Is there a row inside of that table? If so, does it have a unique identifier (index) such as ID?

  9. #9
    Join Date
    Sep 2006
    Location
    Evanston, Illinois.
    Posts
    2,361
    Tokens
    0

    Latest Awards:

    Default

    oh ok..
    caleb if you leave action="" does it like just do php_self, always wondered that..
    How could this hapen to meeeeeeeeeeeeeee?lol.

  10. #10
    Join Date
    Mar 2008
    Posts
    173
    Tokens
    0

    Default

    No, I am pretty sure it doesn't.

Page 1 of 4 1234 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
  •