PDA

View Full Version : attendance tracking using comboBox & PHP & CSV


jaxson
03-13-2005, 04:45 AM
Hello,

I am trying to build an attendance tracking for my baseball team. In short I am trying to use comboBox with name, date, and if they can attend the game. Ultimately I would like to have the data sent to a CSV file for better reporting.

I have been trying to first tackle sending the data to a text file using PHP before trying to send to a CSV file. I have been all over the web and read so many forums and can’t find my answers. If anyone could help me figure out two major areas I can’t seem to figure out.

1. Post data that is selected from a comboBox
2. Using PHP have the selections be sent to a CSV or text file reporting.

I would be so grateful to you. It was created with Flash MX 2004. I have listed the programming code below but if you would like to download the source files you can do so at:

www.ltrcdodgers.com/attend/attend02.zip (http://www.ltrcdodgers.com/attend/attend02.zip)

Here is the flash code on the submit button.

//sending data
on (release) {
myData.who = this.name_cb.selectedItem.label;
myData.date = this.date_cb.selectedItem.label;
myData.yes = this.yes_cb.selectedItem.label;
loadVariablesNum("text.php", myData, "POST");
gotoAndStop(2);
}

Here is the PHP I Frankensteined together but can’t get anything to post in my text file
<?php
$who = $_Post['who'];
$date = $_POST['date'];
$yes = $_POST['yes'];
$toSave ="who=$who, date=$date, yes=$yes";
$fp = fopen("data.txt", "a");
fwrite($fp,$toSave);
fclose($fp);
?>
Thank you in advanced for helping.

stevelux
04-12-2005, 05:55 AM
You've got to break it up and test in phases. Try to ascertain the following:
1. Is Flash sending the right data out to post?

I didn't see a getURL() method in there. That could be a problem. You're trying to load variables from the PHP script "loadVariablesNum" when you should be FEEDING it "gerURL". Assemble the string by concatenating variables and use getURL()

//i.e.
var urlString = "?who=" + myData.who "&date=" + myData.date;
//etc etc.

Switch to GET and see what is output in the URL (text.php?this=this&that=that etc.)

2. Have your PHP echo the data out (<? echo $who; ?>). This is very routine PHP stuff to verify your script can pull everything from the $_POST (not $_Post) array.

3. Does your PHP report errors?

Assuming you can verify:
1. Flash puts the data in either GET or POST correctly for the PHP script
2. All the PHP data is readable and in the $_GET or $_POST arrays (echo cmds)

Lots of picky things can happen in PHP, error reporting will tell you. If you get a blank screen your ISP doesn't have it turned on (call them and they should accomodate).

4. You might not have write capability in the directory or your fopen flags may be wrong. Test the fopen() method with something simple to see if it can really write a file. Permissions may be a factor in this.

Isolate those out and check back. Gotta run (it's late). Post back after you've modified your approach and tried some of the above.