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

  • SEARCH
  • Home
  • 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 6745489
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:12:41+00:00 2026-05-26T12:12:41+00:00

if ($num_rows == 0 && $num_rows2 == 0) { echo ‘result1’; header(‘Location:enter-work.php’); die(); }

  • 0
if ($num_rows == 0 && $num_rows2 == 0) {
    echo 'result1';
    header('Location:enter-work.php');
    die();
} else if ($num_rows >= 0 || $num_rows2 >= 0) {
    echo 'result2';
    header('Location:similar-work.php');
    die();
}

I have the above code that I’m testing with and it properly echos out the sample text ‘result1’ or ‘result2’ every single time I refresh the page with this code, but it is not redirecting to enter-work.php or similar-work.php like it does on my localhost server. On my localhost server, I can even link it to online websites (ie. google.com). And I inputed the above code before any html was written – so before even the doctype was declared.

Not sure what’s causing the problem, need some help.

EDIT: as Pekka mentioned in his comments (on the selected answer) the problem was I had echos and white spaces before the header() function.

  • 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-05-26T12:12:41+00:00Added an answer on May 26, 2026 at 12:12 pm

    You mustn’t output any content before sending headers.

    That the local and live server behave differently if you do, may be because of different output buffering settings.

    Anyway, it should work if you remove the echos.

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

Sidebar

Related Questions

$n=mysql_num_rows($rs); $i=0; while($n>0) { while(($row=mysql_fetch_array($rs))&&$i<=5) { echo $row['room_name']; $i=$i+1; //echo $n.<br>; } echo <br>;
Here is my login PHP code. <?php // rnlogin.php include_once 'rnheader.php'; echo <h3>Member Log
I have list: <td ><a href=#><?php echo $meniu['lovos']; ?></a> <ul> <?php $result = mysql_query(SELECT
I'm a spanking new developer to the PHP & SQL scene. I've only done
<?php $con = mysql_connect (localhost, user, pass) or die ('Error: ' . mysql_error()); mysql_select_db
<?php $objConnect = mysql_connect(localhost,,root) or die(mysql_error()); $objDB = mysql_select_db(mydb); $pic2 = SELECT * FROM
I'm making a simple registration system in php however, even if i enter all
I'm looking for a php script server side that load an image in a
I'm validating a login form with jQuery AJAX call to PHP. In php, I
I have this PHP code : $query = SELECT * FROM news WHERE news_active

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.