essjay_d12 Posted March 14, 2006 Share Posted March 14, 2006 I have the following error pointing at the first echo line...Parse error: parse error, unexpected T_LNUMBER, expecting ',' or ';'[code] <?phpif (isset($_SESSION['username'])) { echo "<td width="143" height="107" valign="top"><p>You are logged in....</p><p>Welcome"; echo $_SESSION['username']; echo "</p><p><a href="logout.php">logout</a></p></td>"; }if (!isset($_SESSION['username'])) { echo "<td width="143" height="107" valign="top"><form id="form1" name="form1" method="post" action="auth2.php">Username:<input type="text" name="username" />Password:<input type="password" name="password" /><input type="submit" name="Submit2" value="Login" /><a href="register.php">Register</a></form></td>"; } ?>[/code]What is wrong there? is it the quotes conflicting? Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted March 14, 2006 Share Posted March 14, 2006 When ever you have double quotes in a string delimited by double quotes you need to escape them or you can surround the string with single quotes.[code]<?php echo "<td width=\"143\" height=\"107\" valign=\"top\"><p>You are logged in....</p><p>Welcome"; echo $_SESSION['username']; echo "</p><p><a href=\"logout.php\">logout</a></p></td>";?>[/code]or[code]<?php echo '<td width="143" height="107" valign="top"><p>You are logged in....</p><p>Welcome'; echo $_SESSION['username']; echo '</p><p><a href="logout.php">logout</a></p></td>';?>[/code]I prefer the second method since it's more readable be humans.Ken Quote Link to comment Share on other sites More sharing options...
essjay_d12 Posted March 14, 2006 Author Share Posted March 14, 2006 I took the quotes out of the html part and it works, but I was wondering if this would have an effect later on somewhere? Quote Link to comment Share on other sites More sharing options...
obsidian Posted March 14, 2006 Share Posted March 14, 2006 [!--quoteo(post=354913:date=Mar 14 2006, 10:31 AM:name=Essjay_d12)--][div class=\'quotetop\']QUOTE(Essjay_d12 @ Mar 14 2006, 10:31 AM) [snapback]354913[/snapback][/div][div class=\'quotemain\'][!--quotec--]I took the quotes out of the html part and it works, but I was wondering if this would have an effect later on somewhere?[/quote]you really don't want to remove the quotes, as then your markup won't validate, but if you use the suggestion above and simply escape the quotes with backslashes, you should be fine. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.