By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,614 Members | 1,680 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,614 IT Pros & Developers. It's quick & easy.

Problem with data not being inserted for online questionaire

P: n/a
Hello All,

I am pretty new to php, and I think this group is the right place to ask
about this problem - please don't flame me if it isn't!

I have an online questionnaire. The idea is that users are allocated a
username and password with which to log in once, and once only to take a
questionnaire. The date and time they used the password (credit) is
logged in a db and they are shown the questionnaire form.

Their log in info is stored in a different db to the information from
the questionnaire. This is how we know testers can log in and get to the
questionnaire page.

When they have completed and successfully submitted the form, which is
validated for required fields by php, you are then notified by email
that some results are available to view on line. A timestamp is recorded
on the email.

The questionnaire script is function based and goes something like this:

validate_reqd_fields();
email_client();
crunch_numbers(); // Also inserts data into the db
update_demog_info(); // demographic information
logout_user();
thank_you_message()

The report is actually a PDF file that is created on-the-fly using the
FPDF class, not that this is where I suspect the problem lies. The data
the PDF is based on is not present in the table, so the problem happens
way before then. This is an excerpt from the script, its part of the
crunch_numbers()function:

// Use a for loop to insert one row per factor
for ($i=2; $i<=13; $i++){

//$this_raw_score = $sum_f$i; // how to get this to work?? - Use
variable
variables
$sum_f = "sum_f" . $i;
$current_score = $$sum_f;
//echo $current_score . "\n
"; // debug

$sql = "INSERT INTO report_lookup SET ".
"credit_id = '" . $_SESSION['crd_id'] . "', ".
"factor_id = '$i', ".
"raw_score = '$current_score'";

if (!mysql_query($sql)) {
echo("Error: " . mysql_error());
}
} // end for

No rows are added at all for the missing data, its not just the
credit_id ie. the $_SESSION['crd_id']

The form is quite long at 112 questions, plus a few other fields, which
has led some people to suggest that it may be due to time related
issues.

The script takes less than 1 second to run, I timed it, so its not
timing out like that.

I'm using the standard file based session handler and all the default
settings.

session.gc_maxlifetime = 1440

session.cookie_lifetime = 0

The '0' means 'until the browser is restarted', so even a very slow test
taker's session would never end before we want it to.

Most users can complete the process without any problems, they can log
in with their test taker password, complete and submit the form

BUT... the problem reported by some beta testers is that when they have
completed the test and submitted it, the questionnaire data does not ake
it across to the database and hence PDF report is not populated with any
data.

I'm using PHP 4.3 and mysql 4.

Does anyone have any ideas on what might be causing the problems? Any
help would be gratefully appreciated.

Thank you for any help you can offer,
--
Liam
Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
In article <5l**************@occpsy.demon.co.uk>, L. Healy wrote:
No rows are added at all for the missing data, its not just the
credit_id ie. the $_SESSION['crd_id']

The form is quite long at 112 questions, plus a few other fields, which
has led some people to suggest that it may be due to time related
issues.


How long is the lifetime of the cookie?

--
Tim Van Wassenhove <http://home.mysth.be/~timvw>
Jul 17 '05 #2

P: n/a
In article <2j************@uni-berlin.de>, Tim Van Wassenhove
<eu**@pi.be> writes
In article <5l**************@occpsy.demon.co.uk>, L. Healy wrote:
No rows are added at all for the missing data, its not just the
credit_id ie. the $_SESSION['crd_id']

The form is quite long at 112 questions, plus a few other fields, which
has led some people to suggest that it may be due to time related
issues.


How long is the lifetime of the cookie?


The cookie is set automatically by the php and lasts until the browser
is restarted.
--
L. Healy
Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.