Hi there,
What I'm trying to achieve with the following code is for the script to search in the database for 'ref' value, and if it doesnt exist or not supplied then display 'defaultcode'.
However, this has confused me a lot

. If I do supply an existing 'ref' value that is in the database I get the actual $code value, but if I supply a value that's not in the database or not supply anything then the 'defaultcode' text is not echoed.
Please let me know what the problem may be.
Thanks
PHP Code:
<?php
$ref = htmlspecialchars(@$_GET["ref"]);
$data = mysql_query("SELECT * FROM table WHERE ref='$ref'") or die(mysql_error());
$info = mysql_fetch_array( $data );
$code = $info['code'];
if($code=="$code")
{
echo "$code";
}
else
{
echo "defaultcode";
}
?>