Ok I have a promblem. Im getting a unidentified variable error from $found:

Whats wrong here?

while($row = mysql_fetch_array($result))
{
    **$found** = true;
    echo "Character/Alias: " . $row["CharName"] . "<br>Created: " . $row["CharBorn"] . "<br>Game: ";
    if ($row["CharGame"] == '0')
    {
        echo "None";
    }
    else
    {
        echo "In-Game";
    }
}
if(!$found)
{
    echo "No Characters/Aliases<br>";
    echo "<a href='create.php'>Create A Character/Alias</a>";
}

Recommended Answers

All 3 Replies

change 14

if(!$found === true)

Hello,
Just declare $found variable above while loop..as currently if records not found in Query..you are geting error.

use below code:

<?php

**$found=false;**
while($row = mysql_fetch_array($result))
{
    $found = true;
    echo "Character/Alias: " . $row["CharName"] . "<br>Created: " . $row["CharBorn"] . "<br>Game: ";
    if ($row["CharGame"] == '0')
    {
        echo "None";
    }
    else
    {
        echo "In-Game";
    }
}
if(!$found)
{
    echo "No Characters/Aliases<br>";
    echo "<a href='create.php'>Create A Character/Alias</a>";
}

?>

$found=false;

thanx. worked out great

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.