Click here to Skip to main content
14,735,597 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am beginner in php programming and am designing a basic website that can add a record, delete records and view all records in a database that was created using PHPmyAdmin.

After I have added a record I want to return to the page I came from, for this I was told to use -

header("Location: View.php");

For this line of code the following error appears -

Parse error: syntax error, unexpected 'header' (T_STRING) in C:\xampp\htdocs\New.php on line 114

Why is this happening and what can I do to fix it ?

What I have tried:

Tried searching websites and youtube videos hoping that they may tell me what the issue is and what can be done about it, but haven't found anything useful.
Posted
Updated 7-Jun-20 2:33am
Comments
Richard MacCutchan 6-Mar-18 9:43am
   
Well unless you show us what is in line 114 it's anyone's guess.

1 solution

The line
header("Location: View.php");
looks fine. But parsing errors may be also sourced by errors on previous lines. So inspect those or edit your question to show them. Common errors are a missing semicolon at the line end and unterminated string literals (missing the terminating single or double quote character or using the wrong one). That seems to apply here because T_STRING indicates a problem with a string literal.

This code should for example generate a similar error:
echo "Using header() function;
header("Location: View.php");
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900