- Home /
Why is my PHP echo returning entire PHP file after WWW request?
I'm having a problem accessing my SQL database after transferring it to a new server.
Previously, the scripts were working very well, but I had to migrate it to a new server (I have set up PHP on the new server, and the phpinfo(); function appears to be working successfully).
I'm calling the PHP page with the WWW class in the same manner as before, and instead of returning an echo value that I am using to determine if the login details were correct or not, it's returning the entire contents of the PHP script, starting from .
Some Google-fu has turned up this:
http://answers.unity3d.com/questions/221881/wwwtext-is-returning-entire-indexphp-page.html
This was caused by the PHP page having HTML on it. My PHP page does not have any HTML on it (as far as I can tell) and the same problem is still occurring.
Does anyone have any advice at all? I simply do not know where to look now.
Thanks in advance. :)
<?
// CONNECTIONS =========================================================
$host = "localhost"; //put your host here
$user = "----"; //in general is root
$password = "----"; //use your password here
$dbname = "----"; //your database
mysql_connect($host, $user, $password) or die("Cant connect into database");
mysql_select_db($dbname)or die("Cant connect into database");
// =============================================================================
$unityHash = anti_injection_login($_POST["myform_hash"]);
$phpHash = "hashcode"; // same code in here as in your Unity game
$useremail = $_POST["myform_nick"];
$userpassword = $_POST["myform_pass"];
if(!$nick || !$pass)
{
echo "Not enough data";
}
else
{
$SQL = "SELECT * FROM database WHERE ouremail = '" . $useremail . "'";
$result_id = @mysql_query($SQL) or die("DATABASE ERROR!");
$total = mysql_num_rows($result_id);
if($total)
{
$datas = @mysql_fetch_array($result_id);
if(!strcmp($userpassword, $datas["userpasswordfield"]))
{
echo "login okay";
}
else
{
echo "Incorrect details";
}
}
else
{
echo "Incorrect details";
}
}
// Close mySQL Connection
mysql_close();
?>
Answer by Dave-Carlile · May 30, 2013 at 11:58 AM
This isn't really a Unity related question, but...
Your file starts out with
<?
By default the short form of the opening tag is disabled. The PHP folks also recommend using the long form of the tag.
<?php
So I would recommend changing to the long form. If you really want to use the short form then enable the PHP.ini setting.
Thank you, I will try and post the result for posterity. :)
(my apologies that it isn't a strictly Unity question)