SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict
    Join Date
    Apr 2001
    Location
    Michigan
    Posts
    284
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Whats wrong with my code?

    I'm doing the php tutorial that Kevin wrote and I've double checked my code, but I can't seem to find the error. I keep getting a parse error on line 62. I'll mark line 62 with ***'s. Any help would be greatly appreciated.

    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>

    <body bgcolor="#FFFFFF" text="#000000">
    <?php
    if (isset($addjoke)):
    ?>

    <FORM ACTION="<?php echo($PHP_SELF); ?>" METHOD=POST>
    <P>Type your joke hereBR>
    <TEXTAREA NAME="joketext" ROWS=10 COLS=40 WRAP></TEXTAREA><BR>
    <INPUT TYPE=SUBMIT NAME="submitjoke" VALUE="SUBMIT">
    </FORM>

    <?php
    else:

    $dbcnx = @mysql_connect("localhost", "root", "mypass");
    if (!$dbcnx) {
    echo ("There was an error connecting to the database.\n" .
    "Please try again later, or contact trhynard@aol.com");
    exit();
    }


    if (!@mysql_select_db("jokes")) {
    echo("The database you are trying to access is unable to be accessed.\n " .
    "Please contact trhynard@aol.com.");
    exit();
    }

    if ("submit" == $submitjokes) {
    $sql = "insert into jokes set " .
    "$joketext = '$joketext', " .
    "$jokedate = $curdate()";
    if (mysql_query($sql)) {
    echo ("Your joke has been added to the database.");
    }
    else {
    echo ("Your joke could not be added to the database.");
    }
    }

    echo("Here are all the jokes in the database:");

    $result = mysql_query("select joketext from jokes");
    if (!$result) {
    echo("An error occured while trying to generate the joke list from the database.\n" .
    "Please contact trhynard@aol.com with the text below: \n" .
    "mysql_error()");
    exit();
    }

    while ($row = mysql_fetch_array($result)) {
    echo($row["JokeText"]);
    }

    echo("<a href='$php_self?addjoke=1'>Add a Joke!</a>");
    ***?>***
    The above line is line 62, i don't know if i missed a } somewhere or what, any help would be greatly appreciated. Thanks.

  2. #2
    You talkin to me? Anarchos's Avatar
    Join Date
    Oct 2000
    Location
    Austin, TX
    Posts
    1,438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    if (isset($addjoke)):
    should be:
    if (isset($addjoke)){

    and you need another } in there somewhere.

  3. #3
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This code uses the alternative control structure syntax:
    http://www.php.net/manual/en/control...ive-syntax.php

    It appears that there is a missing "endif" which I'm guessing probably goes at the very end of the code

    ...
    endif;
    ?>

  4. #4
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by Anarchos
    if (isset($addjoke)):
    should be:
    if (isset($addjoke)){

    and you need another } in there somewhere.
    That is what I thought when someone else was having problems with this script.

    Sean
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature


Bookmarks

Posting Permissions

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