jamjam1123 Posted December 27, 2012 Share Posted December 27, 2012 ////// 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. Quote Link to comment https://forums.phpfreaks.com/topic/272417-is_numeric-data-error-help/ Share on other sites More sharing options...
silkfire Posted December 27, 2012 Share Posted December 27, 2012 var_dump($cat_id) and see what you get? Quote Link to comment https://forums.phpfreaks.com/topic/272417-is_numeric-data-error-help/#findComment-1401572 Share on other sites More sharing options...
Pikachu2000 Posted December 27, 2012 Share Posted December 27, 2012 And get rid of the error suppression @ operators and forget they even exist. Quote Link to comment https://forums.phpfreaks.com/topic/272417-is_numeric-data-error-help/#findComment-1401574 Share on other sites More sharing options...
jamjam1123 Posted December 27, 2012 Author Share Posted December 27, 2012 (edited) var_dump($cat_id) and see what you get? It displays everything that should be there. Where should I start? Sorry I'm a little new at this. Edited December 27, 2012 by jamjam1123 Quote Link to comment https://forums.phpfreaks.com/topic/272417-is_numeric-data-error-help/#findComment-1401640 Share on other sites More sharing options...
Jessica Posted December 27, 2012 Share Posted December 27, 2012 For one, you could tell us what it was. Secondly, did you remove your error suppression? Quote Link to comment https://forums.phpfreaks.com/topic/272417-is_numeric-data-error-help/#findComment-1401641 Share on other sites More sharing options...
jamjam1123 Posted December 27, 2012 Author Share Posted December 27, 2012 When I add var_dump($cat_id); it displays "null" and I removed the suppression I get undefinded index Quote Link to comment https://forums.phpfreaks.com/topic/272417-is_numeric-data-error-help/#findComment-1401647 Share on other sites More sharing options...
Jessica Posted December 27, 2012 Share Posted December 27, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/272417-is_numeric-data-error-help/#findComment-1401649 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.