PHP Variables problem

Hey, I’m trying to make a account ban checker, When I try to give my $id a name from a database, It isn’t working. If I use it for “echo” it works. But If I want to use it for an other DB connection, it doesn’t. ANy idea? Here is my code

[php]

Andor GFX Version 3 <?php include('includes/nav.php'); ?>
    <?php

/* Check if logged in */

include(‘config.php’);

/*
You should make changes in if else loops according to your needs here */

if(isset($_COOKIE[‘username’]))
{
echo “You are logged in as “.$_COOKIE[‘username’].”.”;
/* " $_COOKIE[‘username’] " will fetch the username from cookie stored on browser if user is already looged on */

//or you can redirect it to another page…
}
else
{
header(“location: login.php”);
}

$user = $_COOKIE[‘username’];

?>
Logout

<? $con = mysql_connect("$host","$suser","$spass"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("auth", $con); $result = mysql_query("SELECT * FROM account Where username='$user'"); while($row = mysql_fetch_array($result)) { echo "
"; echo "
"; echo "Last IP" . " : " . $row['last_ip']; echo "
"; echo "Last Login" . " : " . $row['last_login']; } $id = $row['id']; mysql_select_db("auth", $con); $result = mysql_query("SELECT * FROM account_banned Where id='$id'"); while($row = mysql_fetch_array($result)) { echo "Account ID" . " : " . $row['id']; echo "Your account is" . " : " . $row['active']; } ?>
</body>
[/php]

what is [php] echo “Account ID” . " : " . $row[‘id’];[/php] outputting? is it what you expect or is it something completely different? or are you getting any php or mysql errors.
try adding
[php]echo "ERROR ".mysql_error();[/php] to the while loop and see if it outputs "ERROR: " and a space or if there is a mysql error attached to each iteration of the loop like “ERROR: row ‘id’ not found.” for example

Sponsor our Newsletter | Privacy Policy | Terms of Service