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
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-

Link to comment
Share on other sites

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.)

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

$emailcheck = mysql_num_rows($result) or die(mysql_error());

 

I would guess that no rows are returned (so mysql_num_rows() returns 0 which is cast to boolean false), but since query run with no errors, mysql_error() does not return anything.

Link to comment
Share on other sites

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);

Link to comment
Share on other sites

@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');

?>

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.