Reputation: 327
I am getting the error "Uncaught SyntaxError: Unexpected token }" on index.php (line: 30) when i try and run certain functions of my web app (while other functions seem to work fine).
I've slightly narrowed down the problem. The error seems to occur at the "<?php"
opening tag (I found this because adding a line after this tag doesn't change the line the error is given for, but an extra line before the tag and the error is given for line: 31). I've put the code in note-pad++ to check for hidden characters, I couldn't find anything out of place. Dreamweaver gives no syntax errors...
I've also looked at my AJAX JS functions (which are in a separate file). No syntax errors there, no out of place characters either.
QUESTION: Can anyone see or explain what is causing this error?
I'll place the code surrounding "line: 30" where the error is meant to be. The full code is here on github (to large to post all code here):
https://github.com/bcdawber/URL-Vault-Web-Application
CODE:
</head>
<body onLoad="showUrl('All URLs')">
//console suggests error is somewhere here?
<?php
session_start();
if(isset($_SESSION['userid'])) {
echo '<div class="container">';
echo '<div class="panel" id="backgroundPanel">';
echo '<div class="row">';
echo '<div class="large-12 columns">';
echo '<div class="panel">';
echo '<p><h2 id="title">URL VAULT</h2>';
echo '<h4 id="title">A Web Application for Storing URLs to Online Media.</h4></p>';
echo '</div>'; // <!-- END PANEL -->
echo '</div>'; // <!-- END COLUMN (12) -->
echo '</div>'; // <!-- END ROW -->
...........
Upvotes: 0
Views: 2760
Reputation: 20776
In index.php, you have several lines like:
echo '<a href="#" class="small button radius expand" onClick="showUrl("All URLs");return false;"/>All URLs</a>';
echo '<a href="#" class="small button radius expand" onClick="showUrl("Television");return false;"/>T.V URLs</a>';
echo '<a href="#" class="small button radius expand" onClick="showUrl("Movie");return false;"/>Movie URLs</a>';
echo '<a href="#" class="small button radius expand" onClick="showUrl("Music");return false;"/>Music URLs</a>';
The parameters to showURL
are double-quoted, but so is the call to showURL
itself. The parameters to showURL
need to have a double backslash. E.g.
onClick="showUrl(\\"All URLs\\")
Upvotes: 1