Truman Posted May 20, 2016 Author Share Posted May 20, 2016 I give up, totally lost with this synrax... Link to comment Share on other sites More sharing options...
Ingolme Posted May 20, 2016 Share Posted May 20, 2016 There's a closing quote missing on this line: print "\t\tfont-size: " . htmlentites($_COOKIES['font_size']) . "; \n You can tell because all the following lines are colored green by the syntax highlighter. You just need to look at the code more carefully. 1 Link to comment Share on other sites More sharing options...
Truman Posted May 26, 2016 Author Share Posted May 26, 2016 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>Date Menus</title> </head> <body> <?php // Script 10.1 - menus.php function make_date_menus() { $months = array(1 => 'January', 'February', 'March', 'Aprile', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'); print '<select name="month">'; foreach ( $month as $key => $value ) { print "\n<option value=\"$key\">$value</option>"; } print '</select>'; print '<select name="day">'; for ($day=0; $day<=31; $day++) { print "\n<option value=\"$day\">$day</option>"; } print '</select>'; print '<select name="year"> $start_year = date('Y'); for ($y = $start_year; $y <= ($start_year + 10); $y++ ) { print "\n<option value=\"year\">$y</option>"; } print '</select>'; } // end of make_date_menus function. print '<form action="" method="post">'; make_date_menus(); print '</form>'; ?> </body> </html> and the error is: Parse error: syntax error, unexpected 'Y' (T_STRING) in C:\xampp\htdocs\my-site\menus.php on line 23 I don't see why 'Y' is an error, I used already existing function... Link to comment Share on other sites More sharing options...
dsonesuk Posted May 26, 2016 Share Posted May 26, 2016 (edited) where does closing " ' " of print '<select name="year"> end? because $start_year = date('Y'); has taken partially control of ending it! Edited May 26, 2016 by dsonesuk 1 Link to comment Share on other sites More sharing options...
Ingolme Posted May 26, 2016 Share Posted May 26, 2016 These errors are obvious if you would look at the code coloring. Link to comment Share on other sites More sharing options...
dsonesuk Posted May 27, 2016 Share Posted May 27, 2016 Get a decent php editor that will highlight these errors, before you even begin to view in a browser to rely on php error reporting to inform you of the error. Link to comment Share on other sites More sharing options...
Truman Posted May 27, 2016 Author Share Posted May 27, 2016 Thank you, now other mistake is reported, but I won't bother you with that. Do you think that online php code checker is good? It usually sends the same message as browser. Link to comment Share on other sites More sharing options...
dsonesuk Posted May 27, 2016 Share Posted May 27, 2016 No! you just need a editor that checks syntax of your code as you type, and highlights the error, usually with warning triangle against the line in question, as said these errors are highlighted before you even get anywhere near looking for them in a browser. Link to comment Share on other sites More sharing options...
Truman Posted May 27, 2016 Author Share Posted May 27, 2016 Oh, I see. Thank you. Do you think that Sublime Text is good for that purpose? Someone recommended it to me... Link to comment Share on other sites More sharing options...
justsomeguy Posted May 27, 2016 Share Posted May 27, 2016 That's what I use. 1 Link to comment Share on other sites More sharing options...
Truman Posted July 12, 2016 Author Share Posted July 12, 2016 I wrote a simple code for logout: <?php // Script 1.7 - logout.php if (isset($_COOKIE['Samuel'])) { setcookie('Samuel', FALSE, time()-300); } define('TITLE', 'Logout'); include('templates/header.html'); print '<p>You are now logged out.</p>'; include('templates/footer.html'); ?> but I receive:Parse error: syntax error, unexpected '<' in C:\xampp\htdocs\my-site\all\templates\header.html on line 3 This makes no sense to me... Link to comment Share on other sites More sharing options...
justsomeguy Posted July 12, 2016 Share Posted July 12, 2016 The error is on line 3 of the header.html file, you didn't show the code for that. Link to comment Share on other sites More sharing options...
Truman Posted July 13, 2016 Author Share Posted July 13, 2016 How could I know that the error is on line 3 of another file? And this is the code for header.html: <?php // Script 1.4 - header.html include('functions.php'); <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <link rel="stylesheet" media="all" href="css/style.css" /> <title><?php if (defined('TITLE')) { print TITLE; } else { print 'My site of quotes.'; } ?></title> </head> <body> <div id="container"> <h1>My site of quotes.</h1> <br /> <! -- Begin changeable content. --> Link to comment Share on other sites More sharing options...
dsonesuk Posted July 13, 2016 Share Posted July 13, 2016 Simple where error message shows C:\xampp\htdocs\my-site\all\templates\ header.html on line 3 The error is it has open php tag with php code which also includes html code, which should have escaped with closing php tag. 1 Link to comment Share on other sites More sharing options...
Truman Posted July 13, 2016 Author Share Posted July 13, 2016 Thanks, I closed php code before <!DOCTYPE...>' and now it works... Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now