I have a problem with a script I'm using to register variables into a mySQL database. I got the script from a tutorial, and can get the script to read from the database, but not write to it.
the actionscript is as follows:
on (release) {
Status = "Beginning registration Process... Please Hold";
loadVariablesNum ("Register.php?RegName="+RegName,0,"post");
}
this gets data from a text field, the var name of this text field is RegName.
the php for login is as follows:
<?
foreach($HTTP_GET_VARS as $name => $value) { $$name = $value;}
foreach($HTTP_POST_VARS as $name => $value) { $$name = $value;}
foreach($HTTP_COOKIE_VARS as $name => $value) { $$name = $value;}
##The login script accesses the database and checks to see whether your Login name exists. If it does it will select your information from the database and Print it out back to Flash.
##This first line of Code is to load your database variables - The include File should be ##renamed with your database variables.
include ('Include.inc');
##This line of Code changes the name to all UPPERCASE. This is so that the login Name is not ##case sensitive. You can make it case sensitive by leaving this line out.
$Name = strtoupper ($Name);
##This line takes out everything from the $Name variable 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.
$Name = ereg_replace("[^A-Za-z0-9 ]", "", $Name);
#Connects to the database.
mysql_connect($DBhost,$DBuser,$DBpass);
@mysql_select_db("$DBName");
#The SQL query
$query = "SELECT * FROM $table WHERE Name = '$Name'";
$result = mysql_query($query);
#This just gets the number of rows in the Query - It's just a check to see if the Name exists - If not it prints out an error statement.
$numR = mysql_num_rows($result);
#If the number of rows is not equal to one then it prints out an error statement - Name not in Database.
if ($numR == 1) {
print "Status=Success Login Complete&CheckLog=1";
}
else {
print "Status=Failure - Your name was not found - Please register";
}
?>
this works fine.
the php for the register is:
<?
##The registration script adds a record to the SQL database with the user's Name. That's about it.
###This first line of Code is to load your database variables.
include ('Include.inc');
##This line of Code changes the name to all UPPERCASE. This is so that the login Name is not ##case sensitive. You can make it case sensitive by leaving this line out.
$RegName = strtoupper ($RegName);
##This line takes out everything from the $Name variable 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.
$RegName = ereg_replace("[^A-Za-z0-9 ]", "", $RegName);
#Connects to the Database.
$Connect = mysql_connect($DBhost, $DBuser, $DBpass);
@mysql_select_db("$DBName");
#Preforms the SQL query
$insert = "INSERT INTO $table (Name,Object1,Object2,Object3,Comment) VALUES ('".$_POST['$RegName']."','','','','Hello - Edit This')";
$result = mysql_query($insert);
#Gets the number of rows affected by the query as a check.
$numR = mysql_affected_rows($Connect)or die("Status=failure, cannot insert");
if ($numR == 0) {
print "Status=Failure Please Fill out all Fields - Register Again";
}
else if ($numR == 1) {
print "Status=Success You can Now Login - Login";
}
else { print "Status=General Error - UserName already in Use";
}
?>
this script seems to fail if I place an Or Die at $result = mysql_query($insert);
So I assume that the problem is either that the scripting is not right to insert it into the database, or the scripting is not right to send the variables from flash.
This is only the second day that I have been working in this scripting style (flash/php/mySQL)
,So just assume I am an idiot, and know nothing.
thanks for any help.