<html>
<head>
<title>Player Lookup</title>
</head>
<body>
<h2>Player Info</h2>
<?php echo 'hello world' ?>
</body>
</html>
Ok that's pretty simple. But when I replace <?php echo 'hello world ?> with this:
<?php
$link = mysql_connect('localhost', 'root', '*********');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully to database.';
// make player_db current db
$db_selected = mysql_select_db('player_db', $link);
if (!$db_selected) {
die('error: Can not use player_db : ' . mysql_error());
}
// the table im querying is player_info
// a different script was used to get the value for id in _POST
$query = "select * from player_info where name = $_POST['id']";
if (!$query) {
die('Player doesn\'t exist in database: ' . mysql_error());
}
$result = mysql_query($query);
if (!$result) {
$message = 'Invalid query: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $query;
die($message);
while ($row = mysql_fetch_assoc($result)) {
echo $row['name'];
echo $row['country'];
}
mysql_free_result($result);
mysql_close($link); ?>
all of the sudden nothing works. The <title>Player Lookup</title> nor the <h2>Player Info</h2> is not showing up. It's a total blank page.
Obviously, something is wrong with that second script. But what?? I appreciate your help. Btw, Im using PHP 4.3.