Why am I getting this error?

Discussion in 'PHP' started by Procode, May 16, 2010.

  1. #1
    I am building my first PHP based application, and I ran into a problem.

    This is a page where they get to add jokes to the database, I haven't added the code to the part where it ads yet but I built it so it checks if a joke has been submitted, it shows a message, if not then it shows a form. However I keep getting this message as an error:

    Parse error: parse error in C:\wamp\www\testing\test.php on line 38
    Code (markup):
    This is my code:
    <html>
        <head>
        <title>Add a joke!</title>
        <link type="text/css" rel="stylesheet" href="style.css" />
               </head>
               <body>
               <?php
               if(!isset($_GET['submit'])):
                   ?>
    
                   <div class="wrapper">
    	<h2 class="test">Submit Your Own Joke!</h2>
     
    	<form class="simple-form" action="" method="" name="">
    		<label class="label">Name:</label>
    		<input type="text" name="input-1" class="inputfield" />
     
    		<label class="label">E-mail:</label>
    		<input type="text" name="input-2" class="inputfield" />
    
                    <label class="label">Joke Text:</label>
                    <textarea name="input-2" id="input-2" cols="29" rows="9">
    Enter your joke here...</textarea>
     
    		<input type="submit" name="submit" class="submit" value="Add the Joke!">
    	</form>
                   </div>
                   <?php else: ?>
                   <h2>Your Joke has been placed in Que for Moderation,<br />
                       If you followed the guidelines, then it will be added<br />
                       shortly. Thank you for your submission!</h2>
                   <? endif; ?>
    
    
    
               </body>
    </html>
    PHP:
    Thanks in advance!
     
    Procode, May 16, 2010 IP
  2. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #2
    Short_tags are disabled, theirfore replace with the full formal php tags and also use curly brackets as their more widely used.

    <html>
        <head>
        <title>Add a joke!</title>
        <link type="text/css" rel="stylesheet" href="style.css" />
               </head>
               <body>
               <?php
               if(!isset($_GET['submit'])){
                   ?>
    
                   <div class="wrapper">
        <h2 class="test">Submit Your Own Joke!</h2>
     
        <form class="simple-form" action="" method="" name="">
            <label class="label">Name:</label>
            <input type="text" name="input-1" class="inputfield" />
     
            <label class="label">E-mail:</label>
            <input type="text" name="input-2" class="inputfield" />
    
                    <label class="label">Joke Text:</label>
                    <textarea name="input-2" id="input-2" cols="29" rows="9">
    Enter your joke here...</textarea>
     
            <input type="submit" name="submit" class="submit" value="Add the Joke!">
        </form>
                   </div>
                   <?php } else { ?>
                   <h2>Your Joke has been placed in Que for Moderation,<br />
                       If you followed the guidelines, then it will be added<br />
                       shortly. Thank you for your submission!</h2>
                   <?php } ?>
    
    
    
               </body>
    </html>
    PHP:
     
    danx10, May 16, 2010 IP
  3. roopajyothi

    roopajyothi Active Member

    Messages:
    1,302
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    80
    #3
    XAMPP Won't understand php short tags in default!
    i mean it won't understand if you write as
    
     <?     
    //codes here
     ?>
    
    PHP:
    Instead of that write as
    
    <?php   
    //codes here
       ?>
    
    PHP:
     
    roopajyothi, May 17, 2010 IP
  4. abstractworld

    abstractworld Peon

    Messages:
    35
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    In php.ini
    find short_open_tag
    and set its value to "1"

    then restart your server...
    it will enable short tags...

    else use complete php tag as roopa said
     
    abstractworld, May 17, 2010 IP
  5. mginger

    mginger Peon

    Messages:
    280
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #5
    best practice to avoid using short tag at all
     
    mginger, May 18, 2010 IP
  6. c_cicca

    c_cicca Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    I don't see errors to your code, try to use XAMPP not Wamp, i thing is better.
     
    c_cicca, May 18, 2010 IP
  7. abstractworld

    abstractworld Peon

    Messages:
    35
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Both are equally good just difference is in some configuration options which you can change any time.

     
    abstractworld, May 19, 2010 IP