Jump to content

syntax error, unexpected 'REQUEST_METHOD' (T_STRING)


Go to solution Solved by mac_gyver,

Recommended Posts

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 by Nightasy
  • Solution

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.

@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.

@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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.