I am trying to display data from my tables using the following code but nothing is being displayed. I have verified that the data is there in the table inside the database. No echo statements within the while loop is executing. The code that I am using is;
?php
session_start();
$userId = $_SESSION['userId'];
$password = $_SESSION['password'];
$db_host= "localhost";
$db_user = "XXXX_YYYY";
$db_password = "ZZZZ";
$db_name ="XXXX_StudyKitchenData";
$db = mysql_connect($db_host, $db_user, $db_password);
mysql_select_db($db_name, $db);
$sql = "SELECT Email FROM UserDetails WHERE Email = '$userId' AND Password = '$password'";
$result = mysql_query($sql, $db);
if(!mysql_num_rows($result)== 1){
unset($_SESSION['userId'], $_SESSION['password']); // clear bad username/password from session;
header("location:http://www.studykitchen.com/login.php"); // redirect for them to login again
}
$query = "SELECT Page, Date, Time, ID FROM mydiary WHERE Email ='userId'";
$result = mysql_query($query, $db);
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
//I did not get the following echo messages nor any error messages
echo "Date : ".$row['Date']." Time : ".$row['Time']." ID : ".$row['ID']." <br>" .
"".$row['Page']."<br>".
"".$row[<HR color="#0000ff" noshade size="5">]."<br><br>";
}
mysql_close($db);
?>
Please guide.
?php
session_start();
$userId = $_SESSION['userId'];
$password = $_SESSION['password'];
$db_host= "localhost";
$db_user = "XXXX_YYYY";
$db_password = "ZZZZ";
$db_name ="XXXX_StudyKitchenData";
$db = mysql_connect($db_host, $db_user, $db_password);
mysql_select_db($db_name, $db);
$sql = "SELECT Email FROM UserDetails WHERE Email = '$userId' AND Password = '$password'";
$result = mysql_query($sql, $db);
if(!mysql_num_rows($result)== 1){
unset($_SESSION['userId'], $_SESSION['password']); // clear bad username/password from session;
header("location:http://www.studykitchen.com/login.php"); // redirect for them to login again
}
$query = "SELECT Page, Date, Time, ID FROM mydiary WHERE Email ='userId'";
$result = mysql_query($query, $db);
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
//I did not get the following echo messages nor any error messages
echo "Date : ".$row['Date']." Time : ".$row['Time']." ID : ".$row['ID']." <br>" .
"".$row['Page']."<br>".
"".$row[<HR color="#0000ff" noshade size="5">]."<br><br>";
}
mysql_close($db);
?>
Please guide.
Comment