Viewed   95 times

My php script directs to a url depending on which submit button was pressed. However, when I run the test I'm getting an error saying line 4 contains an unexpected ":" but my line 4 is my header script with the url?

I'm confused because I have other scripts similar to this and they don't give me that error. Can anyone tell me what I'm missing, might be simple, I have been caught being simple before.

<?php
if ($_REQUEST['Dish1'] == 'Dish1')
{
header(“Location: http://blahblah”.urlencode($_POST[‘uid’]));
}
else if ($_REQUEST['Dish1'] == 'Dish2')
{
header(“Location: http://blahblah2”.urlencode($_POST[‘uid’]));
}
else if ($_REQUEST['Dish1'] == 'Dish3')
{
header(“Location: http://blahblah3”.urlencode($_POST[‘uid’]));
}
etc.....
?>

 Answers

5

You are using curly quotes.

Replace all the “ ” and ‘ ’ to " and ' respectively.

Tuesday, August 2, 2022
5

Your problem is that the PHP file has been saved with exotic white space characters -- ie not standard spaces, but some other characters that are rendered as spaces (or even not shown at all), but are unparseable by PHP.

Delete all the white space characters on lines 3 and 4, re-type them, and save the file. (that's all white space, including line feeds and spaces between words)

This should solve the problem.

If after doing this, you still get the error, but on a different line, then you will need to repeat the process for that line too.

Sunday, October 23, 2022
 
loki
 
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :