Jump to content

[SOLVED] Works on server, but not on computer


twilitegxa

Recommended Posts

Can anyone tell me why this works on my server, but I can't test it from my home computer? The page just goes to a blank page instead of redirecting to the right page on my computer, but works fine on my server. Here is the code:

 

<?php

session_start();

//Access Tracking Snippet

//set up static variables
$page_title = "charactercreation.php";
$user_agent = getenv("HTTP_USER_AGENT");
$date_accessed = date("Y-m-d");

//connect to server and select database
$conn = mysql_connect("localhost", "root", "")
or die(mysql_error());
$db = mysql_select_db("smrpg", $conn) or die(mysql_error());

//create and issue query
$sql = "insert into access_tracker values
('', '$page_title', '$user_agent', '$date_accessed')";
mysql_query($sql,$conn);

$gender = $_POST['gender']; //Male or female?
$status = $_POST['status']; //Hero or villain?

if($status == "villain"){
//Since you're a villain, we just redirect here to the villain page
header("Location: villain.php");
exit;
}elseif($status == "hero"){
if($gender == "male"){
	//You are a male hero!
	header("Location: knight.php");
exit;
}elseif($gender == "female"){
	//You are a female hero!
	header("Location: scout.php");
exit;
}
}
?>
<title>Sailor Moon RPG - Character Creation - Step 2: Character Outline</title>
</head>
<div id="main">
<?php include("menu.php"); ?>
<h1>Step 2: Character Outline</h1>
<form action="<?=$_SERVER['PHP_SELF']?>" method="post">
<table>
<tr>
<td>Would you like to create a:</td><td><input type="radio" name="status" value="hero" /> Hero or a <input type="radio" name="status" value="villain" /> Villain</td></tr>
<tr><td></td><td><input type="radio" name="gender"value="female" /> Female or <input type="radio" name="gender" value="male" /> Male</td></tr></table><br />
<input type="submit" name="submit" value="Create Character" />
<input type="reset" name="reset" value="Reset" />
</form>
</div>
<?php include("address.php"); ?>
</body>
</html>

 

Anything you can see?

Well, it could be a lot of things. Most probobly due to different configuration or extensions etc. Firstly I am assuming that the white screen is due to an error, however you have error reporting turned off. Therefore turn error reporting on in your PHP config to see this error. It could be that mysql extension isn't set up on your home computer, or the username, password or database are incorrect. All of these could be happening however without the error message it is difficult to know which one.

 

When you turn on the errors, post back.

How do you know error reporting is turned off? I looked, and only only one part of the php.ini file said display_error = off. I changed that, and all others said On. The username and password and everything is right. All my other pages work, just this one has been altered, and now doesn't work. I had originally had the if statements on another page, but now they are on this page because I'm abotu to start using sessions to link the form pages together.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.