Jump to content

Is_Numeric Data Error Help :)


jamjam1123

Recommended Posts

////// Your Database Details here /////////

require "z_db.php"; //Your database details here

//////////////////////////// Main Code sarts ///////////////

@$cat_id=$_GET['cat_id'];

//$cat_id=1;

 

if(!is_numeric($cat_id)){

echo "Data Error "; <----- I'm getting the "data error" message and I'm wondering what the cause is.

exit;

}

 

$message="";

 

if($cat_id>0){

$q=mysql_query("select subcat_id, subcat_name from plus2_subcat where cat_id=$cat_id order by subcat_name");

}else{

$q=mysql_query("select subcat_id, subcat_name from plus2_subcat order by subcat_name ");

$cat_id=0;

}

@$message .= mysql_error();

 

$str= "{ \"data\" : [ ";

 

while($nt=mysql_fetch_array($q)){

$str=$str."{\"subcat_id\" : \"$nt[subcat_id]\", \"subcat_name\" : \"$nt[subcat_name]\"},";

//$str=$str."{"myclass" : "$nt[class]"},";

 

}

$str=substr($str,0,(strLen($str)-1));

$message=$message. " Records displayed";

$str=$str."],\"value\" : [{\"cat_id\" : $cat_id,\"message\" : \"$message\"}]}";

//echo json_encode($str);

 

echo $str;

?>

 

 

This is script I'm trying to edit and it came with a mysql dump so the database is working and is fetch some data but I'm getting this error in one of the drop down menus.

Link to comment
https://forums.phpfreaks.com/topic/272417-is_numeric-data-error-help/
Share on other sites

You just said that it displayed what you expected. Now it's null. 

 

Again, when you get an error, you should post WHAT IT SAYS. Fortunately, it's easy to guess that it's about $_GET['cat_id']. Which means your URL does not contain a query string parameter with the index of cat_id. So, fix that.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.