close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Form Builder Error

Thread began 11/16/2009 8:59 am by iansr393906 | Last modified 12/02/2009 11:48 am by Eric Mittman | 2938 views | 12 replies |

iansr393906

Form Builder Error

I keep on getting this error on any form I create, please help. Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /var/www/vhosts/mch-ok.com/httpdocs/Survery.php:1) in /var/www/vhosts/mch-ok.com/httpdocs/WA_ValidationToolkit/WAVT_ValidatedForm_PHP.php on line 3

I looked through the code and can't seem to find the error. The code for that php is below:

<?php
if (!session_id()) {
session_start();
}
function ValidatedField($page,$field) {
$theFields= "";
$retVal = "";
if (isset($_SESSION["WAVT_".$page."_Errors"])) {
$theFields = "&".$_SESSION["WAVT_".$page."_Errors"];
}
if (strpos($theFields,"&WAVT_".$field."=") !== false) {
$retVal = substr($theFields,strpos($theFields,"&WAVT_".$field."=")+strlen("&WAVT_".$field."="));
}
if (strpos($retVal,"&WAVT_") !== false) {
$retVal = substr($retVal,0,strpos($retVal,"&WAVT_"));
}
if ($retVal == "" && $page == $field) {
$retVal = ValidatedField($page,$field."_Errors");
}
return $retVal;
}

?>

Sign in to reply to this post

iansr393906

More info

Here is the website in a test area, Survery.php

Sign in to reply to this post

Eric Mittman

If it is just a headers issue you should be able to resolve this by finding some white space around the php blocks and deleting it, also there is a BOM option you can have when you save pages in DW, if you have this option enabled for the page you should try disabling it when you save the page. Here is a link to an article that has more info on the white spaces:

81/

If this does not clear up the problem then the issue may be with the session starting and not be able to write the session cookies. If this is the case there may be an issue with your session save path info for you PHP. If you have access to this you should check the php.ini file for this setting and make sure it is set correctly. If you do not have access to this or do not know how to update it you should speak with your host about this.

Sign in to reply to this post

iansr393906

Originally Said By: Eric Mittman
  If it is just a headers issue you should be able to resolve this by finding some white space around the php blocks and deleting it, also there is a BOM option you can have when you save pages in DW, if you have this option enabled for the page you should try disabling it when you save the page. Here is a link to an article that has more info on the white spaces:

81/

If this does not clear up the problem then the issue may be with the session starting and not be able to write the session cookies. If this is the case there may be an issue with your session save path info for you PHP. If you have access to this you should check the php.ini file for this setting and make sure it is set correctly. If you do not have access to this or do not know how to update it you should speak with your host about this.  



Neither one of these solutions corrected the problem. Please Help

Sign in to reply to this post

Eric Mittman

The error you are getting could be a result of just some sort of output occurring, or a problem with the session. To rule out a problem with the session please use these two test pages that I created that will set a value and print it to the screen.

Please load these files and test them and let me know what the result is. If you get the same thing on both pages then the sessions should be working ok. If this is the case please post back with a copy of the survey page in question.

Attached Files
session_test2.zip
Sign in to reply to this post

iansr393906

Results

This was what I got as a result of the session test loading,
the value of the session variable test is: test var
array(1) { ["test"]=> string(8) "test var" }

What would you like to post from my website, the page thats throwing the errors is above.

Sign in to reply to this post

Eric Mittman

I will need to have a copy of the page in question. If you can please post back and include this in a zip archive so I can take a look at it and try to find the problem.

This error about the headers already being sent is one of the most common that you will encounter in a php page. It is almost always due to some sort of white space that occurs outside of the php blocks on the page, most of the time it is the first character in the file.

Sign in to reply to this post

iansr393906

I have attached the page in question. When I spoke to my website host about their possibly being aproblem with the php.ini file this was his response:
Ian,

Output buffering is not something we typically employ, and it is not in use
on the mch-ok.com site. As a result, sessions must be initiated in the
first line of code of the file requested by the server daemon.

It appears that whatever form technology you are trying to implement is
trying to initiate a session after that first line.

You have a few options in this scenario:

1) You could initiate the session at the top of Survey.php.
2) You could see if the form technology can operate without a session.
3) You could see if the form technology provides alternative instructions
for dealing with sessions.


I then went ahead and edited the WAVT_ValidatedForm_PHP.php file and eliminated the session startup and it works fine, but I'm assuming I need it to start a new session? Also could you provide more information on how I would have this form sent in an email, I purchased Universal Email, but I don't quite understand how I get it to work with this form.

Attached Files
Test.zip
Sign in to reply to this post

Eric Mittman

If the problem is where the session is starting then you could start the session at the top of your page with this line of code:

php:
<?php if(!session_id()) session_start(); ?>



This should initiate the session for you if this is how you need to have it for your hosting.

As for the Universal Email there is a Solution Recipe for this that is available on the Universal Email support page that can be found here:

universal-email/

In the Solution Recipes section you can check out the sending the form, it will cover the steps that you need to send the form info in an email. If you have trouble with this or have problems with any formatting in the message let us know and we will be glad to help you out.

Sign in to reply to this post

iansr393906

After doing what you suggested i still get the following error

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /var/www/vhosts/mch-ok.com/httpdocs/Survery.php:1) in /var/www/vhosts/mch-ok.com/httpdocs/WA_ValidationToolkit/WAVT_ValidatedForm_PHP.php on line 1

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...