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 9 of 9

Thread: 3 PHP Questions

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

    Default 3 PHP Questions

    Well, I've started on my portfolio script. So far, so good. I've run in to three errors so far:
    1. Name doesn't appear when adding news
    2. Unexpected "t" after the date
    3. After the PHP there is a bottom DIV, which doesn't display

    Here's my code:
    PHP Code:
    <?php
      
    // Database
      
    include "config.php";
      
      
    //Variables
      
    $title = ($_POST["title"]);
      
    $news = ($_POST["news"]);
      
    $date date('F dS h:i: ');
      
      
    // Some mySQL to fetch your name
    $sql "SELECT * FROM details";
    $check mysql_query("SELECT name FROM details") or die("Onoes! Something is wrong! Please contact loserWILL for assistance (this is an error).");
    while (
    $display mysql_fetch_array($check)) {
    $user $display['user'];
      
      
    // If form has been submitted, display this
      
    if ($_GET["action"] == "submit")
    {
    if (
    $title == "")
        {
            echo 
    "Onoes! Please enter a title.";
            exit;
        }
        
    if (
    $news == "")
        {
            echo 
    "Onoes! Please enter some news.";
            exit;
        }
        
        
    $addnews mysql_query("INSERT INTO `news` (`title`, `name`, `date`, `post`) VALUES ('$title','$name','$date', '$post')"); 
        
        
    //Details are fine
        
    echo "Your news has been added.";
        exit;
        }
      
      
    // Display form
      
    echo ("<form action=\"?action=submit\" method=\"post\">
      <strong>Name:</strong> 
    $user<br />
      <strong>Title:</strong> <input type=\"text\" name=\"title\"><br />
      <strong>News:</strong> <input type=\"text\" name=\"news\"><br />
      <input type=\"submit\" name=\"submit\" value=\"Add News\">
      </form>"
    );
      exit;
      }
    Moved by Agesilaus (Forum Moderator) from Design and Development: Please post in the correct forum next time.
    Last edited by Agesilaus; 27-12-2007 at 05:04 AM.

  2. #2
    Join Date
    Oct 2007
    Location
    UK
    Posts
    471
    Tokens
    0

    Default

    The first problem I can see is that you're missing the ?>

  3. #3
    Join Date
    Dec 2006
    Location
    Swindon
    Posts
    3,299
    Tokens
    215
    Habbo
    dunko

    Latest Awards:

    Default

    Well, I've started on my portfolio script. So far, so good. I've run in to three errors so far:
    1. Name doesn't appear when adding news You have declared '$name', only $user. Try that.
    2. Unexpected "t" after the date Date looks fine?
    3. After the PHP there is a bottom DIV, which doesn't display Dont use exit;
    Try this:
    PHP Code:
    <?php
      
    // Database
      
    include "config.php";
      
      
    //Variables
      
    $title = ($_POST["title"]);
      
    $news = ($_POST["news"]);
      
    $date date('F dS h:i: ');
      
      
    // Some mySQL to fetch your name
    $sql "SELECT * FROM details";
    $check mysql_query("SELECT name FROM details") or die("Onoes! Something is wrong! Please contact loserWILL for assistance (this is an error).");
    while (
    $display mysql_fetch_array($check)) {
    $user $display['user'];
      
      
    // If form has been submitted, display this
      
    if ($_GET["action"] == "submit")
    {
    if (
    $title == "")
        {
            echo 
    "Onoes! Please enter a title.";
            exit;
        }
        
    if (
    $news == "")
        {
            echo 
    "Onoes! Please enter some news.";
            exit;
        }
        
        
    $addnews mysql_query("INSERT INTO `news` (`title`, `name`, `date`, `post`) VALUES ('$title','$user','$date', '$post')"); 
        
        
    //Details are fine
        
    echo "Your news has been added.";
        exit;
        }
      
      
    // Display form
      
    echo ("<form action=\"?action=submit\" method=\"post\">
      <strong>Name:</strong> 
    $user<br />
      <strong>Title:</strong> <input type=\"text\" name=\"title\"><br />
      <strong>News:</strong> <input type=\"text\" name=\"news\"><br />
      <input type=\"submit\" name=\"submit\" value=\"Add News\">
      </form>"
    );
      }

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

    Default

    The name still doesn't show.

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

    Default

    Bump - Does anybody know?

    Edited by mat64 (Forum Super Moderator): Please do not double post, unless you are adding additional information.
    Last edited by mat64; 30-12-2007 at 12:51 PM.

  6. #6
    Join Date
    Apr 2006
    Location
    Leamington Spa
    Posts
    1,375
    Tokens
    72

    Latest Awards:

    Default

    In the database, is the users name stored as "name" or "user"? I think that would be the cause of the problem.
    PHP Code:
    <?php
      
    // Database
      
    include "config.php";

      
    //Variables
      
    $title = ($_POST["title"]);
      
    $news = ($_POST["news"]);
      
    $date date('F dS h:i: ');

      
    // Some MySQL to fetch your name
    $sql "SELECT * FROM `details` ;"//It doesn't look like this line is doing anything?

    $check mysql_query("SELECT `name` FROM `details` ;") or die("Onoes! Something is wrong! Please contact loserWILL for assistance (this is an error).");
    while (
    $display mysql_fetch_array($check)) {
    $user $display[user];

      
    // If form has been submitted, display this
      
    if ($_GET["action"] == "submit")
    {
    if (
    $title == NULL)
        {
            echo 
    "Onoes! Please enter a title.";
            exit;
        }

    if (
    $news == NULL)
        {
            echo 
    "Onoes! Please enter some news.";
            exit;
        }

        
    $addnews mysql_query("INSERT INTO `news` (`title`, `name`, `date`, `post`) VALUES ('$title','$user','$date', '$post')");

        
    //Details are fine
        
    echo "Your news has been added.";
        exit;
        }

      
    // Display form
      
    echo ("<form action=\"?action=submit\" method=\"post\">
      <strong>Name:</strong> 
    $user<br />
      <strong>Title:</strong> <input type=\"text\" name=\"title\"><br />
      <strong>News:</strong> <input type=\"text\" name=\"news\"><br />
      <input type=\"submit\" name=\"submit\" value=\"Add News\">
      </form>"
    );
      }
      
    ?>
    i've been here for over 8 years and i don't know why

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

    Default

    It still doesn't display the name.

  8. #8
    Join Date
    Dec 2006
    Location
    Swindon
    Posts
    3,299
    Tokens
    215
    Habbo
    dunko

    Latest Awards:

    Default

    PHP Code:
    <?php
      
    // Database
      
    include "config.php";
      
      
    //Variables
      
    $title = ($_POST["title"]);
      
    $news = ($_POST["news"]);
      
    $date date('F dS h:i: ');
      
      
    // Some mySQL to fetch your name
    $sql "SELECT * FROM details";
    $check mysql_query("SELECT name FROM details") or die("Onoes! Something is wrong! Please contact loserWILL for assistance (this is an error).");
    while (
    $display mysql_fetch_array($check)) {
    $user $display['name'];
      
      
    // If form has been submitted, display this
      
    if ($_GET["action"] == "submit")
    {
    if (
    $title == "")
        {
            echo 
    "Onoes! Please enter a title.";
            exit;
        }
        
    if (
    $news == "")
        {
            echo 
    "Onoes! Please enter some news.";
            exit;
        }
        
        
    $addnews mysql_query("INSERT INTO `news` (`title`, `name`, `date`, `post`) VALUES ('$title','$user','$date', '$post')"); 
        
        
    //Details are fine
        
    echo "Your news has been added.";
        exit;
        }
      
      
    // Display form
      
    echo ("<form action=\"?action=submit\" method=\"post\">
      <strong>Name:</strong> 
    $user<br />
      <strong>Title:</strong> <input type=\"text\" name=\"title\"><br />
      <strong>News:</strong> <input type=\"text\" name=\"news\"><br />
      <input type=\"submit\" name=\"submit\" value=\"Add News\">
      </form>"
    );
      }

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

    Default

    No worries, I got it. Thanks for all the help.

Posting Permissions

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