Re: Problem with Header()
| From: | (Dave Daniels) | Date: | Thu, 10 Aug 2000 16:46:08 +0000 |
| Subject: | Re: Problem with Header() | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-11176@lists.php.net to get a copy of this message | ||
You've almost got it. First, I'd check the $id variable using isset(), then
run the query if it doesn't exist. No need to run it otherwise.
if (isset($id)) {
header("Location: http://www.domain.com/");
exit;
} else {
$Result=@mysql_query("SELECT * FROM $table WHERE id=$id");
while($row = @mysql_fetch_array($Result))
------------------------
All I want it to do is to check if it's empty and then redirect. Here is my
code:
<html>
<?
$server="localhost";
$username="username";
$password="pass";
$database="database";
$table="table";
@mysql_connect($server, $username, $password) or die("Connection");
@mysql_select_db($database) or die("Database");
?>
<?
$Result=@mysql_query("SELECT * FROM $table WHERE id=$id");
while($row = @mysql_fetch_array($Result))
if ($id) {
header("Location: http://www.domain.com/");
exit;
} else {
$title = $row["title"];
echo "<head>
<title>$title</title>
<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>
<style type='text/css'>
<!--
FORM { margin: 0px 0px}
-->
</style>
</head>";
}
?>