EDIT: Ahhh.. nvm, I found it: die("Error with database".);
should be die("Error with database.");
Might anyone know why the following php script produces no results? I.e., when I ctrl+u in Firefox, a blank screen comes up.
<html>
<head>
<title>Create Base</title>
</head>
<body>
<h1>Create Base</h1>
<form action="bases.php" method="post">
<table>
<tr><td>Name:</td><td><input type="text" name="name" /></td></tr>
</table>
<input type="submit" value="Create Base" />
</form>
<?php
$con = mysql_connect("localhost","user","pass");
if($con == NULL)
{
die("Error with database".);
}
mysql_select_db("alecbenz_rpgProj",$con);
if(isset($_POST["name"]) && $_POST["name"] != "")
{
$sql = "SELECT money FROM users WHERE username = \"".$_COOKIE["user"]."\"";
$result = mysql_query($sql,$con);
$row = mysql_fetch_array($result);
$current_money = $row["money"];
if($current_money >= $cost)
{
$sql = "INSERT INTO bases (name,usr_name) VALUES (\"".$_POST["name"]."\",\"".$_COOKIE["user"]."\")";
mysql_query($sql,$con);
$sql = "UPDATE users SET money = ".($current_money-$cost)." WHERE username = \"".$_COOKIE["user"]."\"";
if(!mysql_query($sql,$con))
{
echo "Error: ".mysql_error();
}
}
else
{
echo "You do not have enough money to create a new base. Current money: $current_money.";
}
}
$sql = "SELECT name FROM bases WHERE usr_name = \"".$_COOKIE["user"]."\"";
$result = mysql_query($sql,$con);
if(mysql_num_rows($result) == 0)
{
$cost = 100;
}
elseif(mysql_num_rows($result) == 1)
{
$cost = 150;
}
elseif(mysql_num_rows($result) == 2)
{
$cost = 200;
}
elseif(mysql_num_rows($result) >= 3)
{
$cost = 300;
}
echo "New bases will cost you ".$cost.".<br /><br />";
$sql = "SELECT name,id FROM bases WHERE usr_name = \"".$_COOKIE["user"]."\"";
$result = mysql_query($sql,$con);
if(mysql_num_rows($result) == 0)
{
echo "No bases currently established.";
}
else
{
echo "<div style=\"text-decoration: underline;\">Current bases:</div><br />";
$counter = 1;
while($row = mysql_fetch_array($result))
{
echo $counter.". ".$row["name"]." <a href=\"delete_base.php?base=".$row["id"]."\">Delete</a><br />";
$counter++;
}
}
?>
<br />
<br />
<a href="index.php">Return</a>
</body>
</html>
The page was working (with other issues I could not resolve), when I moved a block of code to another position. I ftped it, reloaded, and nothing came up. I moved the code back, re-ftped, reloaded, still nothing.