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:

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. :slight_smile:

<?
// 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();

?>

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.