Jump to content

Will not Echo?? but why???


jigsawsoul

Recommended Posts

It will not echo "Registration was successful", and i can't see why at all.. .i've been looking for ages..  :confused:

 

anyone???

 

<?php
ini_set ("display_errors", "1"); 
error_reporting(E_ALL);


session_start();
ob_start();

include('../resources/config.php');
include($config["paths"]["resources"] . 'opendb.php');
include($config["paths"]["resources"] . '_library/login.php');

$email = mysql_real_escape_string($_POST['email']);
$password = mysql_real_escape_string($_POST['password']);

$result = mysql_query("SELECT email FROM projectlogin WHERE email = '$email'");
$emailcheck = mysql_num_rows($result) or die(mysql_error());

echo 'Registration was successful';

include($config["paths"]["resources"] . 'closedb.php');

?>

Link to comment
https://forums.phpfreaks.com/topic/196856-will-not-echo-but-why/
Share on other sites

Ok so you have an error in your php.

 

IF you are on your own computer and/or have accesss to the php.ini file:

Find "Display_Errors" and set to "On".

Then find Log_Errors and set to "On"

Then find "Error_Reporting" and set to "E_ALL";

-----------

Run script again.

=========

 

If you dont have access to php.ini you will have to debug it your self.

 

Put this on the very first line of php: exit("This echo works");

 

If it shows, then move it down a line (!! Follow any includes, ie, move the code into the include file if there is an include ).

 

You will find when it stops echoing and that will be the line thats preventing output.

 

Good Luck.

-CB-

What exact output are you getting? If it is a blank page, what does a 'view source' in your browser show?

 

If you are getting a completely blank page, you likely have a fatal parse error (probably something in one of the included files.) Are you developing and debugging php code on a system with error_reporting set to E_ALL and display_errors set to ON in your php.ini so that php would display all the errors it detects (just setting those two values in your script only shows runtime errors.)

What does a 'view source' show you?

 

You probably have something like an exit; statement being executed in one of the included files. Did you troubleshoot what your code is doing from the point where the last output is occurring up to the point where you are not getting any output?

You've started the output buffer, ob_start(), which will hold all your echo and print in memory, delaying output to the page.  When you're ready to print the contents on the page, you have to use ob_end_flush() or ob_flush().  ob_end_flush() will display the contents on the page and end the output buffer.  It doesn't matter how many echo or print statements you have, as long as you have the output buffer running, it won't show up until you're ready to do so.

Try changing this:

$result = mysql_query("SELECT email FROM projectlogin WHERE email = '$email'");
$emailcheck = mysql_num_rows($result) or die(mysql_error());

 

to this:

 

if(!$result = mysql_query("SELECT email FROM projectlogin WHERE email = '$email'")) {
  die(mysql_error())
};
$emailcheck = mysql_num_rows($result);

@Mchl, this seems to work...

<?php

session_start();

include('../resources/config.php');
include($config["paths"]["resources"] . 'opendb.php');
include($config["paths"]["resources"] . '_library/login.php');

$email = mysql_real_escape_string($_POST['email']);
$password = mysql_real_escape_string($_POST['password']);
$password2 = mysql_real_escape_string($_POST['password2']);

if(!$result = mysql_query("SELECT email FROM projectlogin WHERE email = '$email'")) {
  		die(mysql_error());
}

$emailcheck = mysql_num_rows($result);

echo $email;
echo $password;
echo $password2;

include($config["paths"]["resources"] . 'closedb.php');

?>

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.