Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8617707
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:55:35+00:00 2026-06-12T05:55:35+00:00

I have a php script, with if and else blocks. Both contain echo statements

  • 0

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?'; 

?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T05:55:36+00:00Added an answer on June 12, 2026 at 5:55 am

    You will have an error in

    $row = mysql_fetch_array($result) or die(mysql_error());
    

    Since the number of results is zero, your script will print a warning. Depending on your configuration, it’s possible you see a white-page in stead of the warning.

    Please note the
    or die(..)
    part.

    Since the first part failed (fetching an empty result), the script will die and stop. No code lower than this line will be executed, so no logs, no if, …

    Best solution is to put the fetch_array inside the if (mysql_num_rows(..) == 1 statement, so we are sure there is at least 1 user to fetch

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a PHP script that very much like a commenting system, but requires
I have a PHP script that parses an array using the json_encode() method but
I have PHP script works without problems, like this : while($row4 = mysql_fetch_array($result4)) {
I have php script that creates a temporary watermark image for users that are
I have a PHP script running on my LAMP server that requires certain files
I have a php script that inserts data from an Android app into a
I have a php script validation that looks for some special chars and deletes
I have a php script that watches for the newest json file in a
I have a php script that grabs links from another website. I am storing
I have a PHP script that opens an XML document, gets the DOM and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.