Hello all. I'm having difficulties getting a script I wrote to work like I want it to. Of course, it doesn't help matters that I am brand new to PHP coding, but here is my script. Please take a look at it and tell me where I went wrong. . .
<html>
<body>
<?
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("game", $con);
$name = $_POST["name"];
$password = $_POST["password"];
$result = mysql_query("SELECT * FROM characters WHERE name = '$name'");
$row = mysql_fetch_array($result);
if ($row['name'] = $name)
echo "Name already exists. Please use a different name.";
else
{
mysql_query("INSERT INTO characters (name, level, xp, stats, password)
VALUES ('$name', '1', '0', '10', '$password');
echo "Character created successfully!";
}
mysql_close($con);
?>
</body>
</html>
When I run the script, it does not return anything to the browser, and nothing is created in the mysql database. The values I am giving the form to return are: 'red' and '123' for the name and password respectively.