Hello All, I am having a problem integrating Flash, PHP and MySQL. See below:
I get the values from the user in a Flash Form User Interface
Flash passes the values to the php using actionscripting
the php file uses the HTTP GET method to get the values from the actionscript
the php file then checks to make sure the values are not null (additional check even though this is done on the client side)
the php file then converts all the values to uppercase to eliminate case sensitivity
the php file then strips out any foreign characters (not quite sure how I'm going to get urls from the user yet...http://www.userwebsite.com)
the php file then opens a connection to the MySQL database using the database function mysql_connect (if a connection could not be established, the php exits via a die() function)
the php file then inserts the data into the database using the INSERT INTO sql command with the following syntax:
$query = "INSERT INTO feedback_table (FeedbackFName, FeedbackLName, FeedbackEmail, FeedbackText)
VALUES ('$FeedbackFName', '$FeedbackLName', '$FeedbackEmail', '$FeedbackText')";
$result = mysql_query($query);
the php file then checks to make sure the data was inserted using the following code:
$numR = mysql_num_rows($result);
// If the number of rows is not equal to one then it prints out an error statement
if ($numR == 1) {
print "Status=Success";
}
else {
print "Status=Failure";
}
}
This is where it all falls apart. The data never shows up in the database and I am unable to see any MySQL error messages when I use echo mysql_error(), or mysql_errno()
I am using an WindowsXP machine
I have successfully installed XAMPP for windows
I see the mysqld process in my task manager
I don't know what I am doing wrong. Here is the code below...any assistance would be greatly appreciated!! Thanks!
/******************************************************************************************************************************************/
/* get the data sent by the flash application */
$FeedbackFName = $_GET['FeedbackFName'];
$FeedbackLName = $_GET['FeedbackLName'];
$FeedbackEmail = $_GET['FeedbackEmail'];
$FeedbackText = $_GET['FeedbackText'];
/* check form values */
if(empty($FeedbackFName)|| empty($FeedbackLName)|| empty($FeedbackEmail)|| empty($FeedbackText))
{
print "UNABLE TO RETRIEVE VALUES FROM FLASH APPLICATION";
die();
}
else{
/* This line of Code changes the name to all UPPERCASE. This is so that the input is not case sensitive. You can make it case sensitive by leaving this line out.*/
$FeedbackFName = strtoupper ($FeedbackFName);
$FeedbackLName = strtoupper ($FeedbackLName);
$FeedbackEmail = strtoupper ($FeedbackEmail);
$FeedbackText = strtoupper ($FeedbackText);
/* This line takes out everything that is not a captital or lowercase letter or a interger between 0 and 9. This line is only for security purposes so that users can not enter anything that could disrupt the database. You can take this line out if you want. Or you can allow users to enter other symbols by including a \ followed by that character right after.*/
$FeedbackFName = ereg_replace("[^A-Za-z0-9 ]", "", $FeedbackFName);
$FeedbackLName = ereg_replace("[^A-Za-z0-9 ]", "", $FeedbackLName);
$FeedbackEmail = ereg_replace("[^A-Za-z0-9 ]", "", $FeedbackEmail);
$FeedbackText = ereg_replace("[^A-Za-z0-9 ]", "", $FeedbackText);
// Connects to the database.
if(!mysql_connect($DBhost,$DBuser,$DBpass))
{
print "UNABLE TO CONNECT TO THE DATABASE!!";
echo mysql_errno().": ".mysql_error()."<BR>";
print mysql_errno().": ".mysql_error()."<BR>";
die();
}
mysql_select_db("$DBName");
echo mysql_errno().": ".mysql_error()."<BR>";
print mysql_errno().": ".mysql_error()."<BR>";
print "DATABASE CONNECTION DETECTED SENDING >> ";
echo $QUERY_STRING;
print "TO THE DATABASE USING THE!";
echo $REQUEST_METHOD;
print "METHOD";
//will be sent to the database:
echo $FeedbackFName;
echo $FeedbackLName;
echo $FeedbackEmail;
echo $FeedbackText;
// Use the following query to insert user's data into the database
$query = "INSERT INTO feedback_table (FeedbackFName, FeedbackLName, FeedbackEmail, FeedbackText)
VALUES ('$FeedbackFName', '$FeedbackLName', '$FeedbackEmail', '$FeedbackText')";
//mysql_query = actual database execution statement. Get the result of the execution...success or failure
$result = mysql_query($query);
/* This just gets the number of rows affected with the above Query which should be 1. If exactly 1 row wasn't affected, an error is sent back to the flash app */
$numR = mysql_num_rows($result);
// If the number of rows is not equal to one then it prints out an error statement
if ($numR == 1) {
print "Status=Success";
}
else {
print "Status=Failure";
}
}
?>