| | |
Syntax Error
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jun 2009
Posts: 1
Reputation:
Solved Threads: 0
I'm taking a course in Web development, learning to write PHP and I been working very hard on trying to find the errors in this script. I'm very new to programming and I get confused on where '," belong in the code.
Any suggestions you can give is very helpful. Thanks in advance.
Any suggestions you can give is very helpful. Thanks in advance.
php Syntax (Toggle Plain Text)
<?php /*Display this page $places = 700; ?> <html> <head><title>Fix this script</title> <style type='text/css'> <!-- table { margin-left: 3em; padding: 5; } td { padding: .1in .25in .1in .25in; } h2,h3 { font-weight: bold; text-align: center; } --> </style> </head> <body> <?php $event = "Three Hundredth Annual World Magic Convention" ; $schedule = array("Spells" => 1,"Potions" => 2,"Charms" => 3 ); define("DATE","January 15"); echo "<h2>"style="color: red Announcing the $event"</h2>"; echo "<h3>".DATE."</h3>"; echo "<p>This yearly conference—the premier education and networking forum for the magic community—is the place"; echo "to learn about the most successful magic methodologies and to understand how to integrate new magic technologies into your current practices. </p>"; echo '<p>This year's conference offers the following educational events.</p>'; echo "<table border='1'>" <tr><th>Time</th><th>Session</td></tr>"; foreach($schedule as $name => $time) { echo "<tr> <td>$time</td> <td>$name</td> </tr>"; } echo "</table>; echo "<p style='margin-top: 2em'>Witches and Warlocks! Hurry and sign up! Places are filling up fast. "; echo '<h3>Only $places places left</h3>'; ?> </body> </html>
Last edited by peter_budo; Jun 28th, 2009 at 5:27 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
The problem you are having is with your double quotes.
notice the text in blue, this is a string. You are trying to put double quotes inside a string without escaping them. If you place a backslash directly before a double quote php will take it as a part of the string instead of the string termination:
Also, I don't think it is possible to put a string over multiple lines how you are. You should put them on one line and use '\n' (no quotes) to echo a new-line character.
php Syntax (Toggle Plain Text)
echo "value of the constant CONSTANT: " . CONSTANT;
php Syntax (Toggle Plain Text)
//like this: echo "value of the constant \"CONSTANT\": " . CONSTANT; //not this: echo "value of the constant "CONSTANT": " . CONSTANT;
Also, I don't think it is possible to put a string over multiple lines how you are. You should put them on one line and use '\n' (no quotes) to echo a new-line character.
★ "If your not having fun, your doing something wrong." - Humbug
★ Did I help you out? Did I piss you off? Add to my reputation!
★ The Gabriel Method is a great book for losing weight and keeping healthy - I know Jon Gabriel Personally.
★ Did I help you out? Did I piss you off? Add to my reputation!
★ The Gabriel Method is a great book for losing weight and keeping healthy - I know Jon Gabriel Personally.
It was really buggy but I think I found all the bugs. Below is the corrected code.
php Syntax (Toggle Plain Text)
<?php //Display this page $places = 700; ?> <html> <head><title>Fix this script</title> <style type='text/css'> <!-- table { margin-left: 3em; padding: 5; } td { padding: .1in .25in .1in .25in; } h2,h3 { font-weight: bold; text-align: center; } --> </style> </head> <body> <?php $event = 'Three Hundredth Annual World Magic Convention' ; $schedule = array('Spells' => 1,'Potions' => 2,'Charms' => 3 ); define('DATE','January 15'); echo "<h2>\"style=\"color: red Announcing the $event\"</h2>"; echo '<h3>'.DATE.'</h3>'; echo '<p>This yearly conference—the premier education and networking forum for the magic community—is the place'; echo 'to learn about the most successful magic methodologies and to understand how to integrate new magic technologies into your current practices. </p>'; echo '<p>This year\'s conference offers the following educational events.</p>'; echo '<table border="1"> <tr><th>Time</th><th>Session</td></tr>'; foreach($schedule as $name => $time) { echo "<tr> <td>$time</td> <td>$name</td> </tr>"; } echo '</table>'; echo '<p style=\'margin-top: 2em\'>Witches and Warlocks! Hurry and sign up! Places are filling up fast. '; echo '<h3>Only $places places left</h3>'; ?> </body> </html>
Try not to bump 10 year old threads as it can be really annoying.
http://syntax.cwarn23.net/
My favourite PC. - MacGyver Fan
http://syntax.cwarn23.net/
Smilies: ^_* +_+ v_v -_- *~*` My favourite PC. - MacGyver Fan
![]() |
Similar Threads
- syntax error? .. operator overload method problemo (C)
- syntax error that I just can't seem to find! (Visual Basic 4 / 5 / 6)
- UPDATE syntax error (MySQL)
- Subshell Problem, syntax error...Help please! (Shell Scripting)
- DECLARATION SYNTAX ERROR (for bc 31 user) (C++)
- Parse error, syntax error, Forbids declaration (C++)
Other Threads in the PHP Forum
- Previous Thread: php-mysql-javascript image gallery?
- Next Thread: protecting entire directory with php http authentication
| Thread Tools | Search this Thread |
.htaccess ajax apache api array beginner binary broken cakephp checkbox class cms code cron curl database date directory display download dropdownlist dynamic echo email eregi error execution file files folder form forms function functions google href htaccess html image include insert integration ip java javascript joomla jquery key library limit link login loop mail menu mlm mod_rewrite multiple mysql oop overwrite paypal pdf pdfdownload php phpvotingscript problem query radio random recursion regex remote screen script search server sessions sms soap sorting source space sql startup syntax system table tutorial update upload url validation validator variable video web xml youtube zend






