Application Delegate error on save add new child record - no

A place for users and developers of the Xataface to discuss and receive support.

Postby Aoirthoir » Mon Sep 18, 2006 9:15 am

This is the error I get:

Warning: Cannot modify header information - headers already sent by (output started at C:\Servers\xampp\htdocs\MedAct\conf\ApplicationDelegate.php:37) in C:\Servers\xampp\htdocs\libraries\dataface\actions\new_related_record.php on line 99

(No laughing..yes I am testing on a widoze machine....)

My ApplicationDelegate looks like this:

getLoggedInUser();
* if ( !isset($user) ) return Dataface_PermissionsTool::NO_ACCESS();
* // if the user is null then nobody is logged in... no access.
* // This will force a login prompt.
* $role = $user->val('ROLE');
* return Dataface_PermissionsTool::getRolePermissions($role);
* // Returns all of the permissions for the user's current role.
* }
*/

function block__html_title(){
echo "MyProg";

}


}
?>

And so line 37 is the last line of AppDelegate. If I remove the appDelegate I get no errors. So I am not sure if it is a medact error or a Xamp error. (Getting less and less fond of all versions of xamp..including their linux stuff....)
Aoirthoir
 
Posts: 420
Joined: Wed Dec 31, 1969 5:00 pm

Postby shannah » Mon Sep 18, 2006 9:20 am

Your editor is adding whitespace after the closing ?> tag. Make sure there are no blank lines or even spaces after this. Some editors lie to you and make it appear that there is no trailing whitespace, when they have actually added some hidden chars.. try a few different editors. I have used Crimson Editor on Windows and it seems to be real about what whitespace there is.

-Steve
--
Steve Hannah
@shannah78 (on twitter)
sjhannah.com blog
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby shannah » Mon Sep 18, 2006 9:21 am

Alternatively you can use output buffering.

Add ob_start();
at the beginning of your index.php file

And ob_end_flush() at the end of it.

This will prevent whitespace from being output until the end.


-Steve
--
Steve Hannah
@shannah78 (on twitter)
sjhannah.com blog
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby Aoirthoir » Mon Sep 18, 2006 9:27 am

Thanks that solved it. I am using Notetab. It showed whitespace at the end. I just forgot that in some cases php doesnt allow that. You've put xamp back in my good graces :D

Thanks Mr. Steve.
Aoirthoir
 
Posts: 420
Joined: Wed Dec 31, 1969 5:00 pm

Postby Aoirthoir » Thu Sep 21, 2006 1:51 pm

Mr. Steve,

Verifying this issue also. As I understand from memory, PHP does not allow whitespace at the end of a php file? Is this correct?

Also, what about the smarty templates files? Or other files in the database system. Is this a standard, no end whitespace? Or just the .php files?

Thank you kindly for your time.
Aoirthoir
 
Posts: 420
Joined: Wed Dec 31, 1969 5:00 pm

Postby shannah » Thu Sep 21, 2006 2:38 pm

PHP does allow whitespace at the end of its files (following the ?>). The problem comes when we are sending headers (like redirects, cookies, etc..) to the browser. Headers must be sent before any output to the browser. Unfortunately when a PHP encounters white space at the end of the file it is the same as if you had done:


echo " ";

which writes to the browser - precluding the possibility of sending headers. The errors that you got were because Dataface was trying to send a redirect header after whitespace was already written to the browser.

This is not a problem with smarty templates, because they are compiled into PHP echo statements (essentially) that are only called when we want them to be called.

Another solution for this is to use PHP output buffering. Adding a call to ob_start() at the beginning of your app, will prevent output to the browser until:

a. Execution completes
b. or you call ob_end_flush()

Best regards

Steve
--
Steve Hannah
@shannah78 (on twitter)
sjhannah.com blog
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby Aoirthoir » Thu Sep 21, 2006 3:08 pm

Thank you kindly. Noted and closed.
Aoirthoir
 
Posts: 420
Joined: Wed Dec 31, 1969 5:00 pm


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 38 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved