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

Thread: PHP Help

  1. #1
    Join Date
    Jun 2007
    Location
    England
    Posts
    495
    Tokens
    0

    Default PHP Help

    Hey

    I have having touble adding this into the database it says Successfull but then there is nothing in the database

    PHP Code:
    <?php
    if($_GET['add'] == "yes"){
    //Get Data
    $client $_POST['client'];
    $date $_POST['date'];
    $byy $_POST['by'];
    $invoice $_POST['invoice'];
    $acc $_POST['ac'];
    if(
    $by == NULL $invoice == NULL){
    echo 
    "<br /><div class='failed'>You left something blank.<br><a href='javascript:history.back();'>[Back?]</a></div>";
    }else{
    include(
    "config.php");
    $add_invoice "INSERT INTO invoice (client_id, date, created, for, activ) VALUES ('$client','$date','$byy','$invoice','$acc')";
    mysql_query($add_invoice);
    //Added?
    echo "<br /><div class='success'>The invoice for client ID#$client was added successfully!</div>";
    }}
    ?>
    Whats up with it?

    Dan

    Moved by Agesilaus (Forum Moderator) from Design and Development: Please post in the correct forum in future.
    Last edited by Agesilaus; 15-12-2007 at 11:27 AM.


  2. #2
    Join Date
    Jun 2006
    Posts
    4,832
    Tokens
    0

    Latest Awards:

    Default

    Hey, I quickly edited it a bit and fixed something I thought might be a problem. Tell me if it works!

    PHP Code:
    <?php
    if($_GET['add'] == "yes"){
    //Get Data
    $client $_POST['client'];
    $date $_POST['date'];
    $byy $_POST['by'];
    $invoice $_POST['invoice'];
    $acc $_POST['ac'];
    if(
    $byy == NULL $invoice == NULL){
    echo 
    "<br /><div class='failed'>You left something blank.<br><a href='javascript:history.back();'>[Back?]</a></div>";
    }else{
    include(
    "config.php");
    $add_invoice mysql_query("INSERT INTO `invoice` (`client_id`, `date`, `created`, `for`, `activ`) VALUES ('$client','$date','$byy','$invoice','$acc')");
    //Added? Should be!
    echo "<br /><div class='success'>The invoice for client ID#$client was added successfully!</div>";
    }
    }
    ?>
    Last edited by Hitman; 15-12-2007 at 10:52 AM.

  3. #3
    Join Date
    Jun 2005
    Posts
    4,795
    Tokens
    0

    Latest Awards:

    Default

    Question: Where do you actually connect to the database?

  4. #4
    Join Date
    Jun 2006
    Posts
    4,832
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by Tomm View Post
    Question: Where do you actually connect to the database?
    He has got a connection, after the }else{ he connects then does the query. I always connect on the third line.

  5. #5
    Join Date
    Jun 2007
    Location
    England
    Posts
    495
    Tokens
    0

    Default

    Hey its

    PHP Code:
    include("config.php"); 
    That connects

    And its working fine now +rep for help


  6. #6
    Join Date
    Jun 2006
    Posts
    4,832
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by Luno1599 View Post
    Hey its

    PHP Code:
    include("config.php"); 
    That connects

    And its working fine now +rep for help
    My code worked? Hah, I finally can fix things (I'm still a bit of a PHP newbie).

  7. #7
    Join Date
    Aug 2006
    Location
    Manchester, UK
    Posts
    2,016
    Tokens
    141
    Habbo
    florx

    Latest Awards:

    Default

    Quote Originally Posted by Hitman View Post
    He has got a connection, after the }else{ he connects then does the query. I always connect on the third line.
    Me too I like to have the database connected on EVERY page even if it's not going to be used

  8. #8
    Join Date
    Jun 2006
    Posts
    4,832
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by FlorX View Post
    Me too I like to have the database connected on EVERY page even if it's not going to be used
    I think I have it on every page, at least all that need connecting.

    ... But most of the PHP pages I make require the connection anyway.

  9. #9
    Join Date
    Jun 2007
    Location
    England
    Posts
    495
    Tokens
    0

    Default

    I have it on every page as the check.php file has it and it includes it , in a php newbie to

    Check what im making in projects


  10. #10
    Join Date
    Sep 2006
    Location
    Hobart, Australia
    Posts
    593
    Tokens
    0

    Default

    Just a heads up, if you're actually going to be releasing this as a script, you'll want to be sanitizing your form input before chucking it into the database.

Posting Permissions

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