I’m trying to connect to my database but I am having alot of trouble and I keep getting a 500 error. NOTE: I took out the database info because I don’t want you guys knowing the code. =P
Gridnum = mysql_real_escape_string(_GET[‘GridNumber’], $dbname);
echo “OLOL {$Gridnum}”
$result = mysql_query(“SELECT * FROM medsouzNATION WHERE GridId=$Gridnum”) or die(mysql_error());
$row = mysql_fetch_array( $result );
echo “UMG {$row[‘Terrain’]}”
Are you sure the error 500 isn’t caused by something wrong in the server itself?
Also, try adding ; after echoes and putting ’ around the $Gridnum in your query.
Thanks, I know it isn’t the server because the other PHP scripts (that I didn’t make but put there) work fine. This is my first attempt at coding in PHP. I’ll try the echos though.
Okay the PHP isn’t broken anymore but when I try and retreive the data through Unity it fails, here is the PHP(once again with database data taken out):
$Gridnum = $_GET['GridNumber'];
$result = mysql_query("SELECT * FROM medsouzNATION WHERE GridId='$Gridnum'") or die(mysql_error());
$row = mysql_fetch_array( $result );
if ($row){
echo $row['TerType'];
}
else {
echo "No row found...";
}
Here is the simplifiedf Unity3D javascript code:
var num = 1;
var form = new WWWForm();
form.AddField( "GridNumber", num);
var w = WWW(PHP, form);
yield w;
Debug.Log(w.data);
Everytime I try and retreive the data through Unity I get
I found a way around this issue by using another script instead of the large one it was in. I have no clue why it worked this way and not the other way… :?
Oh well this new way is faster (Runs even when you not in the scene so it preloads).