Anything wrong with this script? (PHP)

Hitman
Soldato
Joined
25 Feb 2004
Posts
2,837
Hey,

Having some strange problems with this particular script. It doesn't load or anything, just shows a white blank page.

PHP:
<?php

	$db_host = "1";
	$db_user = "2";
	$db_pwd = "3";
	$db_name = "4";
	
	mysql_connect($db_host, $db_user, $db_pwd);
	mysql_select_db($db_name);

	if (!isset($_POST["submit"]))
	{

		echo("
		<form action="" method=\"post\">
		Player ID: <input type=\"text\" name=\"playerid\"><br />
		XP Amount: <input type=\"text\" name=\"xp\"><br />
		Race: <input type=\"text\" name=\"race\"><br />
		Skill 1: <input type=\"text\" name=\"skill1\"><br />
		Skill 2: <input type=\"text\" name=\"skill2\"><br />
		Skill 3: <input type=\"text\" name=\"skill3\"><br />
		Skill 4: <input type=\"text\" name=\"skill4\"><br />
		<br />
		<input type=\"submit\" name=\"submit\" value=\"Submit\">
		</form>
		Race List<br />
		<br />
		1 => Undead Scourage<br />
		2 => Human Alliance<br />
		3 => Orcish Horde<br />
		4 => Night Elves of Kalimdor<br />
		5 => Blood Mage<br />
		6 => Shadow Hunter<br />
		7 => Warden<br />
		8 => Crypt Lord<br />
		9 => Chameloen
		");

	} 
	else
	{
	
		$playerid = $_POST["playerid"];
		$xp = $_POST["xp"];
		$race = $_POST["race"];
		$skill1 = $_POST["skill1"];
		$skill2 = $_POST["skill2"];
		$skill3 = $_POST["skill3"];
		$skill4 = $_POST["skill4"];

		mysql_query("DELETE FROM `war3users` WHERE playerid='".$playerid."' AND race='".$race."'") or die(mysql_error());
		mysql_query("INSERT INTO `war3users` (playerid, xp, race, skill1, skill2, skill3, skill4) VALUES ('".$playerid."', '".$xp."', '".race."', '".skill1."', '".skill2."', '".skill3."', '".skill4."') or die(mysql_error());

		echo("
		Ta
		");

	}
	
?>

I've used this to do other things, such as just sending a DELETE query, which works fine. But I'm stumpted to why this one doesn't work :confused:

Would appreciate any help on this :)

Cheers.
 
Last edited:
Dj_Jestar said:
stick
Code:
display_errors(1);
error_reporting(E_ALL);
at the top, sounds like you are getting an error with DB stuff but it's not displaying errors.

Done. Still loads a blank page though, showing nothing (even in the source of the page) :/
 
Dj_Jestar said:
replace it all with:
Code:
<?php

phpinfo();

?>

If that doesn't display anything, contact your host (or if a local install, reinstall webserver and php.) :)

That works fine. The rest of the site is coded in PHP (including a forum, among other things) which is all running with no problems. I've used the script in the original post on 4 other pages (slightly edited), but for some reason this one just won't load at all.

Matt
 
JonD said:
place echo "Test"; just before the if statement, if that doesnt print its obviously the database connection.

Done, and again it just shows a blank page. I don't know how this could be a database issue, seeing as the user/pass/etc is all correct, and the other scripts work fine :|

Cheers anyway.
 
JonD said:
Change your connection to:

PHP:
mysql_connect($db_host, $db_user, $db_pwd) or die(mysql_error());
mysql_select_db($db_name) or die(mysql_error());

See what that comes up with

Also add an echo test at the top of the page and see if the page is actually opening.

Added and nothing shows up. Also tried the echo at the very top and it doesn't show either. So strange :confused:
 
Augmented said:
display_errors needs to be enabled via:
Code:
ini_set('display_errors', 1);

There's a syntax issue in your INSERT query:
Code:
mysql_query("INSERT INTO `war3users` 
(playerid, xp, race, skill1, skill2, skill3, skill4) 
VALUES 
('".$playerid."', '".$xp."', '".[b][color=yellow]race."', '".skill1."', '".skill2."', '".skill3."', '".skill4."'[/color][/b])
 or die(mysql_error());

Not sure how I managed to miss that, fixed that. Added the correct display errors and still doesn't show anything.

I may just leave this, absolutly no idea why it doesn't want to load.

Cheers.
 
Beansprout said:
PHP:
 echo("...<form action=\"\" method=\"post\">...
2 minor changes in addition to Augmented's. You'll kick yourself :)

:o :o :o

How on earth did I miss that. Cheers mate, all fixed :)
 
Back
Top Bottom