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.

  1. if(isset($result['testfield'])){$testfield = "ok"; echo $testfield};
  2. if(!empty($result['testfield'])){$testfield = "ok"; echo $testfield};
  3. 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

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -