null - Undefined Variable in PHP -
i have testfield in db
testfield = null i ran query:
$query = mysql_query("select testfield table"); $result = mysql_fetch_array($query); i tried different way no error. i'm still getting "undefined variable" error.
if(isset($result['testfield'])){$testfield = "ok"; echo $testfield};if(!empty($result['testfield'])){$testfield = "ok"; echo $testfield};if($result['testfield']=='1'){$testfield = "ok"; echo $testfield};
please help. thanks!
mysql_fetch_assoc function intended use. mysql_fetch_array give array default:
$result[0] = null;
just use mysql_fetch_assoc , should fine.
a tip when debugging type print_r($result); , see output get.
Comments
Post a Comment