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!
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:
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:
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
Both are equally good just difference is in some configuration options which you can change any time.