Hi I am a total newbie when it comes to PHP right now in flash I have a game and I want to have users post thier highscores I have downloaded an dexample and I cannot get it working. It posts blank entries in my table, but with the get_score.php script provided I can view the table perfectly I just have to manually insert values via webmin.
Heres the php code to put the variables in my database. There is also a data.php file I am using that has my login, my databse and table information and stuff. Another thing I am able to create tables in Mysql using php.
heres the code to submit the score to my database. I know this code has something in it to where the name field is only created once so theres not multiple scores on the same list I dont really care about that code at all if someone could take that out for me itd be appreciated because I have no idea where that part starts or ends.
<?
//*Made by: Jeroen den HaanAlias's: jeroen84 / Jer'ul****
include_once ("_data.php");
$conn = mysql_connect($db_host,$db_user,$db_pass);
mysql_select_db($db_name,$conn);
if ($pass==$add_pass) {
if ($u_user==1) {
$sql3 = "SELECT name FROM $db_table ORDER BY name";
$result3 = mysql_query($sql3);
while($r = mysql_fetch_object($result3))
{
$tmp = "{$r->name}";
if ($name==$tmp) {
$n_exist=1;
}
}
if ($n_exist==1) {
$sql1 = "UPDATE $db_table SET score='$score' WHERE name=\"$name\"";
$result1 = mysql_query($sql1);
} else {
$sql1 = "INSERT INTO $db_table (name,score) VALUES (\"$name\",\"$score\")";
$result1 = mysql_query($sql1);
}
} else {
$sql1 = "INSERT INTO $db_table (name,score) VALUES (\"$name\",\"$score\")";
$result1 = mysql_query($sql1);
}
$sql2 = "SELECT id FROM $db_table ORDER BY score DESC";
$result2 = mysql_query($sql2);
$num = 1;
while($r = mysql_fetch_object($result2))
{
$result = mysql_db_query($db_name,"SELECT * from $db_table WHERE id='{$r->id}'");
$resultArray = mysql_fetch_array($result);
$did = $resultArray["id"];
$name = $resultArray["name"];
$score = $resultArray["score"];
if ($num>$sec_size) {
$sql3 = "DELETE FROM $db_table WHERE id='$did'";
$result3 = mysql_query($sql3);
}
$num++;
}
}
print $name;
print $score;
mysql_close ($conn);
?>
[/COLOR]
I added the print name and scores to see if there values were even being shown in PHP and there not. Heres the code I am using in flash to post the variables by the way I used get instead of post and they were actually getting out of flash because I could see them in the address bar. But it still didnt work
on (release) {
root.name = name;
root.score = score;
this.loadVariables("new_score.php", "POST");
}[/COLOR]
When I dont create an add_pass variable the program will put the blank fields into my database but when im using the pass var it dosent work so thats why I left that var out in my flash as.
Im not sure what the problem is at all ive been at it for 3 days now like I stated above it can post a field into my database but both fields are blank. Any help would be greatly appreciated.