So I looked into other threads but didnt find a solution that worked for me.
Here is my problem:
the first page is supposed to get information from a form, look for it in a database, store it in a variable $_SESSION['$dataArray'] and send it to the second page.
On the second page it gives an error: Uncaught SyntaxError: Unexpected token < result.php:20.
When I look in the source in chrome it says: var schoolData = <br />
<b>Notice</b>: Undefined index: $dataArray in <b>C:\xampp\htdocs\highschools.bg\result.php</b> on line <b>23</b><br />

How is this an unidentified index? When i can only go to the second page after visiting the first, where I assing a value to $_SESSION['$dataArray'].
How can I solve this?

2 Years
Discussion Span
Last Post by mattster

Ideally (for good practice PHP) $_SESSION['$dataArray'] should be $_SESSION['dataArray']. No need for a $ sign within a variable text.

However I'm not sure this is your problem, saying that the variable is undefined suggests an error in defining or add a value to the variable.

Are you certain that you variable is being set correctly? Maybe to check, add echo $_SESSION['$dataArray'] and see what the result is. If it chucks out the right thing, the cause isn't here. If it spits out the wrong thing or an error, then we know where the problem is occurring: setting your value.


If $dataArray is a variable then your session token should be $_SESSION[$dataArray] without the quotes in the square brackets.


Well thats what I thought, but theres no $dataArray defined in his code?

@Borzoi I think you're probably right, if you are, it would've been very helpful of him to have shown what $dataArray was.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.