I have a php script, with if and else blocks. Both contain echo statements only. The if block executes perfectly but when the else block executes nothing at all is printed to screen (not even the echo statements OUTSIDE the blocks). I have tried many things such as capitalising the ELSE statement, checking all the braces are there, double and triple checking the syntax to no avail. Please help.
<?php
// Inialize session
session_start();
// Include database connection settings
include('config.inc');
$usr = mysql_real_escape_string($_POST['****ID']);
// Retrieve email address and message from database according to user's input
$query = "SELECT * FROM users WHERE username = '$usr'";
$result = mysql_query($query) or die(mysql_error());
// Put the id numbers in array $row
$row = mysql_fetch_array($result) or die(mysql_error());
// Test for ID match
if (mysql_num_rows($result) == 1)
{
echo 'The email address of ';
echo $usr;
echo ' is: ';
echo $row['email'];
echo '<p>Message: ';
echo $row['firstname'];
}
else
{
echo 'Sorry it appears that ';
echo '$usr';
echo ' has not registered yet. Why dont you tell him about ****Jacker?';
}
// Executing outside if..else blocks for testing
echo 'Sorry, it appears that ';
echo '$usr';
echo ' has not registered yet. Why dont you tell him about ****Jacker?';
?>