Nightasy Posted May 23, 2013 Share Posted May 23, 2013 (edited) Greetings, I am new to PHP coding and am currently enrolled in a course at my college that is, well, in my opinion poorly designed. Unfortunately I am stuck with the course so I have to do the best I can with what material they have provided. Working on my second assignment for the course I am having a bit of a problem. This is a very basic script with just enough in it that it should run but I get an error when attempting to test it out. Parse error: syntax error, unexpected 'REQUEST_METHOD' (T_STRING) on line 17 //Initialize pagetitle and include header file $pagetitle = 'David Wilson, IT250 Unit 2'; include('includes/header.php); ?> <form action="unit02.php" method="post"> <fieldset> <label for="gasprice">Gas Price</label> <input type="text" name="gasprice"/> <input type="reset" value="Reset"/> <input type="submit" value="Submit"/> </fieldset> </form> <?php //Check if the form was submitted if ($_SERVER['REQUEST_METHOD'] == 'POST') { if (isset($_POST['gasprice'] && is_numeric($_POST['gasprice']) { $gasprice = $_POST['gasprice']; echo $_POST['gasprice']; } else { echo 'wtf'; } //Include footer file include('includes/footer.php'); ?> The other two pages are as follows. header.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"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title><?php echo $pagetitle; ?></title> <link rel="stylesheet" href="includes/styles.css" type="text/css" /> </head> <body> footer.php </body> </html> Any help would be appreciated. As I stated before, this is a very simple draft of the actual assignment. I just wanted it to at least allow me to see my form so I can tweak it. Unfortunately I can't even get the form to load. Best Regards, Nightasy Edited May 23, 2013 by Nightasy Quote Link to comment https://forums.phpfreaks.com/topic/278331-syntax-error-unexpected-request_method-t_string/ Share on other sites More sharing options...
davidannis Posted May 23, 2013 Share Posted May 23, 2013 You are missing a closing curly brace } Quote Link to comment https://forums.phpfreaks.com/topic/278331-syntax-error-unexpected-request_method-t_string/#findComment-1431894 Share on other sites More sharing options...
Solution mac_gyver Posted May 23, 2013 Solution Share Posted May 23, 2013 if you look at the color highlighting in your posted code, it will lead you to the source of the problem, because the colors change to that of a quoted string and don't change back. hint: there's a missing single quote ' near the end of a line. Quote Link to comment https://forums.phpfreaks.com/topic/278331-syntax-error-unexpected-request_method-t_string/#findComment-1431895 Share on other sites More sharing options...
Nightasy Posted May 23, 2013 Author Share Posted May 23, 2013 @davidannis - Thanks for that. I sure did miss that one. @mac_gyver - Thank you very much. I see that I missed that ' in the include command. Colors all changed up in my IDE now. Unfortunately I got another error now but I am one step further. I'll fool around with this now on my own and see what I can do. Thanks very much for the help. Quote Link to comment https://forums.phpfreaks.com/topic/278331-syntax-error-unexpected-request_method-t_string/#findComment-1431896 Share on other sites More sharing options...
davidannis Posted May 23, 2013 Share Posted May 23, 2013 I missed that. mac_gyver is right. You need to fix both issues. Quote Link to comment https://forums.phpfreaks.com/topic/278331-syntax-error-unexpected-request_method-t_string/#findComment-1431897 Share on other sites More sharing options...
Nightasy Posted May 23, 2013 Author Share Posted May 23, 2013 @davidannis - Yea the primary issue was the one that mac_gyver pointed out. I had a feeling the if else statements were going to be wrong. Getting past that error I was able to finish the project in no time flat. So sad that I spent nearly half my morning wrecking my brain over a single quotation mark. Quote Link to comment https://forums.phpfreaks.com/topic/278331-syntax-error-unexpected-request_method-t_string/#findComment-1431907 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.