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 2 12 LastLast
Results 1 to 10 of 11
  1. #1
    Join Date
    Jun 2006
    Posts
    4,832
    Tokens
    0

    Latest Awards:

    Default Not inserting my query AGAIN!?

    Man, my coding is getting better. I see no problems with this, nor does Beau. But the problem is this: It wont insert the info into the database! I don't get any error messages or anything... the vars work, I've tested. It's just not putting anything into the db!

    PHP Code:
    <?php
    include 'config.php';
    session_start();
    $date date("d/m/Y");

    foreach(
    $_POST as $key=>$val) {

    $
    $key clean($val);

    }

    if (
    $_SESSION['logged_user'] == true) {
        
    $query mysql_query("SELECT * FROM `users` WHERE `username` = '".$_SESSION['logged_user']."'");

        
    $rows mysql_fetch_array($query);
        
    if (
    $rows['level'] == 5) {     
        if (
    $_POST['submit']) {
                echo 
    "News added!";
    $sql mysql_query("INSERT INTO `news` (title, shortcontent, content, by, date) VALUES ('$title','$shortcontent','$content',''".$_SESSION['logged_user']."'','$date')");
    }
        if (!
    $_POST['submit']){
            echo 
    "<form action=\"addnews.php\" method=\"POST\">
            News title: <input type=\"text\" size=\"20\" name=\"title\">
            </br>
            </br>
            Short content: <input type=\"text\" size=\"20\" name=\"shortcontent\">
            </br>
            </br>
            Content: <input type=\"text\" size=\"20\" name=\"content\">
            </br>
            </br>
            <input type=\"submit\" name=\"submit\" value=\"Add news!\">
            </form>
            "
    ;
    }
    } else {
        echo 
    "You're not meant to be here, shoo. <meta http-equiv=\"REFRESH\" content=\"1;url=./members.php\">";
    }
    } else {
        echo 
    "Not logged in... Redirecting... <meta http-equiv=\"REFRESH\" content=\"1;url=./login.php\">";
    }
    ?>
    Tell me whats wrong!

  2. #2
    Join Date
    Jan 2007
    Location
    England, Uk, World, Universe,
    Posts
    1,012
    Tokens
    0

    Latest Awards:

    Default

    PHP Code:
                           <?php
    include 'config.php';
    session_start();
    $date date("d/m/Y");

    foreach(
    $_POST as $key=>$val) {

    $
    $key clean($val);

    }

    if (
    $_SESSION['logged_user'] == true) {
        
    $query mysql_query("SELECT * FROM `users` WHERE `username` = '".$_SESSION['logged_user']."'");

        
    $rows mysql_fetch_array($query);
        
    if (
    $rows['level'] == 5) {     
        if (
    $_POST['submit']) {
                echo 
    "News added!";
    echo (
    "$sql");
    $sql mysql_query("INSERT INTO `news` (title, shortcontent, content, by, date) VALUES ('$title','$shortcontent','$content',''".$_SESSION['logged_user']."'','$date')");
    }
        if (!
    $_POST['submit']){
            echo 
    "<form action=\"addnews.php\" method=\"POST\">
            News title: <input type=\"text\" size=\"20\" name=\"title\">
            </br>
            </br>
            Short content: <input type=\"text\" size=\"20\" name=\"shortcontent\">
            </br>
            </br>
            Content: <input type=\"text\" size=\"20\" name=\"content\">
            </br>
            </br>
            <input type=\"submit\" name=\"submit\" value=\"Add news!\">
            </form>
            "
    ;
    }
    } else {
        echo 
    "You're not meant to be here, shoo. <meta http-equiv=\"REFRESH\" content=\"1;url=./members.php\">";
    }
    } else {
        echo 
    "Not logged in... Redirecting... <meta http-equiv=\"REFRESH\" content=\"1;url=./login.php\">";
    }
    ?>
    my sig ran away,

  3. #3
    Join Date
    May 2007
    Location
    Nebo, NC, USA
    Posts
    2,517
    Tokens
    0

    Latest Awards:

    Default

    PHP Code:
    <?php
    include 'config.php';
    session_start();
    $date date("d/m/Y");

    if (
    $_SESSION['logged_user'] == true) {
        
    $query mysql_query("SELECT * FROM `users` WHERE `username` = '" $_SESSION['logged_user'] .
            
    "'");

        
    $rows mysql_fetch_array($query);

        if (
    $rows['level'] == 5) {
            if (
    $_POST['submit']) {
                echo 
    "News added!";
                
    $title $_POST["title"];
                
    $shortcontent $_POST["shortcontent"];
                
    $content $_POST["content"];
                
    $username $_SESSION["logged_user"];
                
    mysql_query("INSERT INTO news (title, shortcontent, content, by, date) VALUES ('$title', '$shortcontent', '$content', '$username', '$date')");
                
            }
            if (!
    $_POST['submit']) {
                echo 
    "<form action=\"addnews.php\" method=\"POST\">
            News title: <input type=\"text\" size=\"20\" name=\"title\">
            </br>
            </br>
            Short content: <input type=\"text\" size=\"20\" name=\"shortcontent\">
            </br>
            </br>
            Content: <input type=\"text\" size=\"20\" name=\"content\">
            </br>
            </br>
            <input type=\"submit\" name=\"submit\" value=\"Add news!\">
            </form>
            "
    ;
            }
        } else {
            echo 
    "You're not meant to be here, shoo. <meta http-equiv=\"REFRESH\" content=\"1;url=./members.php\">";
        }
    } else {
        echo 
    "Not logged in... Redirecting... <meta http-equiv=\"REFRESH\" content=\"1;url=./login.php\">";
    }
    ?>

  4. #4
    Join Date
    Jan 2007
    Location
    England, Uk, World, Universe,
    Posts
    1,012
    Tokens
    0

    Latest Awards:

    Default

    try that
    my sig ran away,

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

    Latest Awards:

    Default

    But why is
    foreach($_POST as $key=>$val) {

    $$key = clean($val);

    } taken away on dentafrices? It works for register. It's in config btw.

    Dentafrice it still doesn't work.
    Last edited by Hitman; 01-12-2007 at 10:47 PM.

  6. #6
    Join Date
    Jan 2007
    Location
    England, Uk, World, Universe,
    Posts
    1,012
    Tokens
    0

    Latest Awards:

    Default

    then try mine ;0
    my sig ran away,

  7. #7
    Join Date
    May 2007
    Location
    Nebo, NC, USA
    Posts
    2,517
    Tokens
    0

    Latest Awards:

    Default

    Because I don't like doing it that way, I think it is better to define your own.

    If someone used firebug or any other program for that matter to make their own field for something..

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

    Latest Awards:

    Default

    Quote Originally Posted by Dentafrice, View Post
    Because I don't like doing it that way, I think it is better to define your own.

    If someone used firebug or any other program for that matter to make their own field for something..
    But then for my protection of the $_POST's... I used clean($_POST['whatever']); but it broke something once... is that better (clean($_POST['whatever']);) though?

    I tried yours rh4u! No luck.

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

    Latest Awards:

    Default

    I can't edit...

    Anybody know what's wrong? I can insert manually in phpMyAdmin but not with this.

    :s

  10. #10
    Join Date
    May 2007
    Posts
    971
    Tokens
    1,516
    Habbo
    Jabbaboy

    Latest Awards:

    Default

    Try:
    PHP Code:
     <?php
    include 'config.php';
    session_start();
    $date date("d/m/Y");

    foreach(
    $_POST as $key=>$val) {

    $
    $key clean($val);

    }

    if (
    $_SESSION['logged_user'] == true) {
        
    $query mysql_query("SELECT * FROM `users` WHERE `username` = '".$_SESSION['logged_user']."'");

        
    $rows mysql_fetch_array($query);
        
    if (
    $rows['level'] == 5) {     
        if (
    $_POST['submit']) {
                echo 
    "News added!";
    $by $_SESSION['logged_user'];
    $sql mysql_query("INSERT INTO `news` (`title`, `shortcontent`, `content`, `by`, `date`) VALUES ('$title','$shortcontent','$content','$by','$date')") or die('Could not insert data, Error: 'mysql_error());
    }
        if (!
    $_POST['submit']){
            echo 
    "<form action=\"\" method=\"POST\">
            News title: <input type=\"text\" size=\"20\" name=\"title\">
            </br>
            </br>
            Short content: <input type=\"text\" size=\"20\" name=\"shortcontent\">
            </br>
            </br>
            Content: <input type=\"text\" size=\"20\" name=\"content\">
            </br>
            </br>
            <input type=\"submit\" name=\"submit\" value=\"Add news!\">
            </form>
            "
    ;
    }
    } else {
        echo 
    "You're not meant to be here, shoo. <meta http-equiv=\"REFRESH\" content=\"1;url=./members.php\">";
    }
    } else {
        echo 
    "Not logged in... Redirecting... <meta http-equiv=\"REFRESH\" content=\"1;url=./login.php\">";
    }
    ?>
    Will also display any MySQL errors if there are any.
    Email: [email protected] | Don't Have Skype or anything else.

Page 1 of 2 12 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
  •