Code: Select all
<?php
include 'connect.php';
session_start();
////Get shorter variable names
$userName = $_POST['username'];
$password = $_POST['password'];
$password = md5($password);
////Query db for username and password for comparison
$query = "SELECT * from players where name='$userName'";
$qResults = mysqli_query($db, $query) or die("Could not query db to get player info.");
$qArray = mysqli_fetch_assoc($qResults);
////See if any results were found.
if (!$qArray) {
echo "No player found. Please try again.<br />";
echo "<a href='login.php'>Try again.</a>";
exit;
}
////See if the password is incorrect
if ($password != $qArray['password']) {
echo "Password incorrect. Please try again. <br />";
echo "<a href='login.php'>Try again.</a>";
exit;
}
////Check to see if a playername is already being stored in $_SESSION, perhaps
////if the player used their browser to come back to this page. If there is
////no session name stored, create one
if (!isset($_SESSION['cPlayer'])) {
$_SESSION['cPlayer'] = $userName;
}
////Welcome the player, and retrieve news from the 'news' table
echo "Welcome ".$_SESSION['cPlayer']."!<br />";
?>
<br />
<b><u>News:</u></b>
<?php
$nQuery = "SELECT * from news WHERE newsid=(select MAX(newsid) from news)";
$nResult = mysqli_query($db, $nQuery);
$nArray = mysqli_fetch_assoc($nResult);
////Make sure news was found and fail gracefully if it was not
if (!isset($nArray['text'])) {
echo "No news found. Please check back for more news later. <br />";
echo "<p>Enter the game!</p><br />";
echo "<a href='mapscreen.php'>Enter</a>";
exit;
}
////Assume news was found, and display for the user
if (isset($nArray['text'])) {
echo "$nArray['text']";
}
////Display the link for the player to
////enter the game
echo "<br />";
echo "<p>Enter the game!</p><br />";
echo "<a href='mapscreen.php'>Enter</a>";
?>Here is line 66:Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in C:\wamp\www\blastedsky\loginproc.php on line 66
Code: Select all
////Make sure news was found and fail gracefully if it was not
if (!isset($nArray['text'])) {
echo "No news found. Please check back for more news later. <br />";
echo "<p>Enter the game!</p><br />";
echo "<a href='mapscreen.php'>Enter</a>";
exit;
}
////Assume news was found, and display for the user
if (isset($nArray['text'])) {
echo "$nArray['text']"; //<<<<<<<<<<<<<<<<<-----Line 66
}
////Display the link for the player to
////enter the game
echo "<br />";
echo "<p>Enter the game!</p><br />";
echo "<a href='mapscreen.php'>Enter</a>";
I just can't figure this one out. I have already used the $nArray['text'] value in a conditional in the lines above it and I don't think it was a problem there. So what is the problem with displaying it?