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!


Results 1 to 10 of 10
  1. #1
    Join Date
    Apr 2008
    Location
    Derby
    Posts
    4,668
    Tokens
    262

    Latest Awards:

    Default Anyone help me with this? [PHP]

    So.. i have this:

    PHP Code:
    <?php
    include ("config.php");
    $event = ($_POST['event']);
    $where = ($_POST['where']);
    $when = ($_POST['when']);
     
    mysql_query("INSERT INTO event (event, where, when) VALUES ('$event', '$where', '$when')")
    or die(
    mysql_error());
    ?>
    And it's worked alot in the past...

    But now i get this error:

    Code:
    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 'where, when) VALUES ('testing', 'testsin', 'testing')' at line 1

    Anyone help please??? Also, If anyone can give me tips on security, then i'll be extremely grateful!
    Back for a while

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

    Latest Awards:

    Default

    PHP Code:
     <?php
    include ("config.php");
    $event = ($_POST['event']);
    $where = ($_POST['where']);
    $when = ($_POST['when']);
     
    mysql_query("INSERT INTO event (event, `where`, when) VALUES ('$event', '$where', '$when')")
    or die(
    mysql_error());
    ?>
    Escape where with `, it's reserved.

  3. #3
    Join Date
    Apr 2008
    Location
    Derby
    Posts
    4,668
    Tokens
    262

    Latest Awards:

    Default

    Thanks alot, I see now!
    Back for a while

  4. #4
    Join Date
    Apr 2005
    Posts
    4,614
    Tokens
    90

    Latest Awards:

    Default

    Also, you haven't added any security to your $_POST variables.

  5. #5
    Join Date
    Sep 2008
    Posts
    718
    Tokens
    0

    Default

    he told me it didn't work on msn caleb :p
    +.net - omg it's coming o_o

  6. #6
    Join Date
    Apr 2008
    Location
    Derby
    Posts
    4,668
    Tokens
    262

    Latest Awards:

    Default

    YhYh, still not wokring :L

    maybe its because `when` ?? as well as `where`

    and how can i add security to $_POST variables?
    Back for a while

  7. #7
    Join Date
    Jul 2008
    Posts
    535
    Tokens
    75

    Default

    Quote Originally Posted by Obulus View Post
    YhYh, still not wokring :L

    maybe its because `when` ?? as well as `where`

    and how can i add security to $_POST variables?
    Use google to figure out how to add security to those variables. And just change your field names to something else and you'll be fine.

  8. #8

    Default

    PHP Code:
    <?php
    include 'config.php';
    $event $_POST['event'];
    $where $_POST['where'];
    $when $_POST['when'];

    mysql_query"INSERT INTO `event` ( event, where, when ) VALUES ( '$event' , '$where' , '$when' )" ) or die( mysql_error() );
    ?>
    How can you read your code, pft.
    Try that.

  9. #9
    Join Date
    Aug 2005
    Location
    Standing on the rooftops...
    Posts
    1,501
    Tokens
    6
    Habbo
    ReviewDude

    Latest Awards:

    Default

    Quote Originally Posted by Obulus View Post
    and how can i add security to $_POST variables?
    Something along the lines of:

    PHP Code:
    <?php
    include ("config.php");
    $event mysql_real_escape_string($_POST['event']);
    $where mysql_real_escape_string($_POST['where']);
    $when mysql_real_escape_string($_POST['when']);
     
    mysql_query("INSERT INTO event (event, where, when) VALUES ('$event', '$where', '$when')")
    or die(
    mysql_error());
    ?>
    I'm sure I'll get shouted down for a far better way of adding security, but that's what I'd use.
    The sunlight hurts my eyes...

    ~ Love, Patrick ~


    Know your stuff about Habbo? I'm looking for high-quality article writers - PM for more!

    I am Habbox's most trusted seller of VIP/Donator - over 100 months total sold without issue.

  10. #10
    Join Date
    Apr 2008
    Location
    Derby
    Posts
    4,668
    Tokens
    262

    Latest Awards:

    Default

    Quote Originally Posted by ReviewDude View Post
    Something along the lines of:

    PHP Code:
    <?php
    include ("config.php");
    $event mysql_real_escape_string($_POST['event']);
    $where mysql_real_escape_string($_POST['where']);
    $when mysql_real_escape_string($_POST['when']);
     
    mysql_query("INSERT INTO event (event, where, when) VALUES ('$event', '$where', '$when')")
    or die(
    mysql_error());
    ?>
    I'm sure I'll get shouted down for a far better way of adding security, but that's what I'd use.

    Two Words; Thank you

    Ive sorted the INSERT INTO last night, new the security issue was something to do with escape string, final piece of the puzzle
    Thanks alot!
    Back for a while

Posting Permissions

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