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 2 of 2 FirstFirst 12
Results 11 to 13 of 13
  1. #11
    Join Date
    May 2007
    Posts
    10,481
    Tokens
    3,140

    Latest Awards:

    Default

    You could add the current contents of the file to the top when it is being rewritten I guess... I am going in about 2 minutes so no time :/
    Chippiewill.


  2. #12
    Join Date
    Jul 2007
    Location
    Scotland
    Posts
    529
    Tokens
    0

    Default

    Not tested, hopefully should work. Updates or inserts into DB and overwrites or creates a new file for the name. Change any form variables and DB stuff, I also assumed you'd have a config file or something you could include:

    PHP Code:
    <?php

    if($_POST['details']) {

        
    $name $_POST['name'];
        
    $x $_POST['x_coord'];
        
    $y $_POST['y_coord'];
        
        if(
    mysql_num_rows(mysql_query("SELECT * FROM `db_name` WHERE `name` = '$name'")) > 0) {
        
            
    $upd mysql_query("UPDATE `db_name` SET `x_cord` = '$x' AND `y_cord` = '$y' WHERE `name` = '$name'") or die(mysql_error());
        
        }
        
        else {
        
            
    $ins mysql_query("INSERT INTO `db_name` (`name`, `x_cord`, `y_cord`) VALUES ('$name', '$x', '$y')") or die(mysql_error());
        
        }

        
    $file $name '.txt';
        
    $f_op fopen($file);
        
    $string 'x_cord = ' $x '\n';
        
    $string .= 'y_cord = ' $y;
        
    fwrite($f_op$string);
        
    fclose($f_op);
        
    }

    ?>
    Last edited by RichardKnox; 23-06-2009 at 10:11 PM.

  3. #13
    Join Date
    Dec 2007
    Posts
    2,807
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by RichardKnox View Post
    Not tested, hopefully should work. Updates or inserts into DB and overwrites or creates a new file for the name. Change any form variables and DB stuff, I also assumed you'd have a config file or something you could include:

    PHP Code:
    <?php

    if($_POST['details']) {

        
    $name $_POST['name'];
        
    $x $_POST['x_coord'];
        
    $y $_POST['y_coord'];
        
        if(
    mysql_num_rows(mysql_query("SELECT * FROM `db_name` WHERE `name` = '$name'")) > 0) {
        
            
    $upd mysql_query("UPDATE `db_name` SET `x_cord` = '$x' AND `y_cord` = '$y' WHERE `name` = '$name'") or die(mysql_error());
        
        }
        
        else {
        
            
    $ins mysql_query("INSERT INTO `db_name` (`name`, `x_cord`, `y_cord`) VALUES ('$name', '$x', '$y')") or die(mysql_error());
        
        }

        
    $file $name '.txt';
        
    $f_op fopen($file);
        
    $string 'x_cord = ' $x '\n';
        
    $string .= 'y_cord = ' $y;
        
    fwrite($f_op$string);
        
    fclose($f_op);
        
    }

    ?>
    Works like a dream, cheers

Page 2 of 2 FirstFirst 12

Posting Permissions

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