# Accessing a database with a php script from Unity mobile game

So I am attempting to keep track of some user data in my game that I am creating in Unity 3d. I am using Unity's WWW class to do this. I am following this tutorial: http://wiki.unity3d.com/index.php?title=Server_Side_Highscores

I am not sure why but I keep getting a 404 error even though the file is on the server. I am using godaddy to host my website and I have the php script that I am trying to access in there so that it can use it to query the database. I am using "http://www.mysite/myscript.php?" followed by the values that I want to push to the database, as the tutorial shows to do.

No matter what I do I end up with a 404 and it doesn't make any sense as I know that it is there in the path I am attempting to connect to. If I type out the path to the php file in a browser it will take me to a page that gives an error about the hash not existing (since I am not passing one unless it is in my game) so I know that the file is there.

3/18/16

Here is my php script to add the values to the database.

<?php
$server = "MyServersIP";$user = "MyUser";
$pass = "MyPassword";$db = "MyDB";

$conn = mysql_connect($server, $user,$pass);

mysql_select_db($db);$Username = mysql_real_escape_string($_GET['Username'],$db);
$Fuel = mysql_real_escape_string($_GET['Fuel'], $db);$IAPCar1 = mysql_real_escape_string($_GET['IAPCar1'],$db);
$IAPCar2 = mysql_real_escape_string($_GET['IAPCar2'], $db);$Score = mysql_real_escape_string($_GET['Score'],$db);
$Level = mysql_real_escape_string($_GET['Level'], $db);$Wins = mysql_real_escape_string($_GET['Wins'],$db);
$Losses = mysql_real_escape_string($_GET['Losses'], $db);$Ads = mysql_real_escape_string($_GET['Ads'],$db);
$LicensePlate = mysql_real_escape_string($_GET['LicensePlate'], $db);$hash = $_GET['hash'];$secretKey = "mySecretKey";

$real_hash = md5($Username . $Fuel .$IAPCar1 . $IAPCar2 .$Score .     $Level .$Wins . $Losses .$Ads . $LicensePlate .$hash);
if ($real_hash ==$hash)
{
$query = "INSERT INTO Player values (NULL, '$Username', '$Fuel', '$IAPCar1', '$IAPCar2', '$Score', '$Level', '$Wins', '$Losses', '$Ads', '$LicensePlate');";$result = mysql_query($query); } mysql_close($conn);
?>

Here is the code I use to call the php script:

public string setValues = "http://www.mysite.com/Set_Values.php?";
private string secretKey = "SecretKeyFromThePhpScript";
public void SetValues(string username, int fuel, bool iapCar1, bool iapCar2, int score,
int level, int wins, int losses, bool ads, string licensePlate, bool firstTime)
{
string hash = Md5Sum(string.Format("{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}", username, fuel, iapCar1, iapCar2,
The solution to my issue turned out to be that I had a typo in my url that I used. Also I needed to change $db to$conn where I am getting the values and assigning them to variables.