jigsawsoul Posted March 29, 2010 Share Posted March 29, 2010 It will not echo "Registration was successful", and i can't see why at all.. .i've been looking for ages.. 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'); ?> Quote Link to comment https://forums.phpfreaks.com/topic/196856-will-not-echo-but-why/ Share on other sites More sharing options...
ChemicalBliss Posted March 29, 2010 Share Posted March 29, 2010 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- Quote Link to comment https://forums.phpfreaks.com/topic/196856-will-not-echo-but-why/#findComment-1033438 Share on other sites More sharing options...
PFMaBiSmAd Posted March 29, 2010 Share Posted March 29, 2010 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.) Quote Link to comment https://forums.phpfreaks.com/topic/196856-will-not-echo-but-why/#findComment-1033439 Share on other sites More sharing options...
jigsawsoul Posted March 29, 2010 Author Share Posted March 29, 2010 I just have hosting on Justhosting.com, not sure how to set on these errors.. never displays after the line $emailcheck = mysql_num_rows($result) or die(mysql_error()); but its display the echo from above this line just fine Quote Link to comment https://forums.phpfreaks.com/topic/196856-will-not-echo-but-why/#findComment-1033440 Share on other sites More sharing options...
PFMaBiSmAd Posted March 29, 2010 Share Posted March 29, 2010 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? Quote Link to comment https://forums.phpfreaks.com/topic/196856-will-not-echo-but-why/#findComment-1033445 Share on other sites More sharing options...
zeodragonzord Posted March 29, 2010 Share Posted March 29, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/196856-will-not-echo-but-why/#findComment-1033449 Share on other sites More sharing options...
PFMaBiSmAd Posted March 29, 2010 Share Posted March 29, 2010 That has nothing to do with his problem. He is getting output up to some point on the page and the output buffer is automatically flushed when the php script ends. Quote Link to comment https://forums.phpfreaks.com/topic/196856-will-not-echo-but-why/#findComment-1033455 Share on other sites More sharing options...
Mchl Posted March 29, 2010 Share Posted March 29, 2010 $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. Quote Link to comment https://forums.phpfreaks.com/topic/196856-will-not-echo-but-why/#findComment-1033456 Share on other sites More sharing options...
jigsawsoul Posted March 29, 2010 Author Share Posted March 29, 2010 view source, shows a blank page... included files, have nothing wrong with them, ill check through them, but there also in other pages, and they have no problem running.. Quote Link to comment https://forums.phpfreaks.com/topic/196856-will-not-echo-but-why/#findComment-1033461 Share on other sites More sharing options...
Mchl Posted March 29, 2010 Share Posted March 29, 2010 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); Quote Link to comment https://forums.phpfreaks.com/topic/196856-will-not-echo-but-why/#findComment-1033462 Share on other sites More sharing options...
jigsawsoul Posted March 29, 2010 Author Share Posted March 29, 2010 @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'); ?> Quote Link to comment https://forums.phpfreaks.com/topic/196856-will-not-echo-but-why/#findComment-1033466 Share on other sites More sharing options...
Mchl Posted March 29, 2010 Share Posted March 29, 2010 It doesn't die in silence, but also does nothing useful. Quote Link to comment https://forums.phpfreaks.com/topic/196856-will-not-echo-but-why/#findComment-1033469 Share on other sites More sharing options...
jigsawsoul Posted March 29, 2010 Author Share Posted March 29, 2010 @Mchl, why does it work this way and not the other way around... Quote Link to comment https://forums.phpfreaks.com/topic/196856-will-not-echo-but-why/#findComment-1033471 Share on other sites More sharing options...
ignace Posted March 29, 2010 Share Posted March 29, 2010 Because in Mchl's example it will die() when you have a query error. In your example the script ends (blank page) whenever mysql_num_rows() returns 0 Quote Link to comment https://forums.phpfreaks.com/topic/196856-will-not-echo-but-why/#findComment-1033472 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.