Wednesday, January 9, 2019

mysql - How to solve Notice: Undefined index: id in C:xampphtdocsinvmgtmanufactured_goodschange.php on line 21




I have a problem with my PHP code saying that "Notice: Undefined index" I am sure its very simple, since I am a beginner i am not getting well what is wrong exactly so please help me.



Here's the code





$id=$_GET['id'];


$query=mysql_query("select * from manuf where id='$id' ")or die(mysql_error());
$row=mysql_fetch_array($query);

?>


































Answer



You are not getting value of $id=$_GET['id'];



And you are using it (before it gets initialised).



Use php's in built isset() function to check whether the variable is
defied or not.




So, please update the line to:



$id = isset($_GET['id']) ? $_GET['id'] : '';

No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...