Hello everyone, On the code below I've got three undefined variables (name, comments and ID). How can I defined these three variables to be active on the code. Thanks>>> <?php error_reporting(E_ALL); ?> <body bgcolor="#CCCCFF"><?php mysql_connect("localhost", "root", "") or die('Error' . mysql_error()); mysql_select_db("test1"); // update data in mysql database $sql="UPDATE testtable SET name='$name', comments='$comments' WHERE ID='$id'"; $result=mysql_query($sql); // if successfully updated. if($result){ echo "Successful"; echo "<BR>"; echo "<a href='update3.php'>View result</a>"; } else { echo "ERROR"; } ?> PHP:
<?php $name='name_you_update'; $comments='comment_you_update'; $id='id_to_update'; ?> PHP: Add this code above this line: $sql="UPDATE testtable SET name='$name', comments='$comments' WHERE ID='$id'"; PHP:
Hi Bitist.. Thanks a lot I've all three variables defined now... but in another code I've this code withe undefined error.. How can I adjust it? // get value of id that sent from address bar $id=$_GET['ID']; PHP:
yes, bartoly13 it's just notice. and it shown that Notice: Undefined index: ID any idea how to define it?
its only a notice, its not an error... you can either define it as "" or null or you can just put @ to disable the notice ie. $variable = @$_GET['variable'];
if it works but spills up errors, just disable PHP errors on your server. technically variables need to be defined at execution but sometimes they dont get defined until later, this causes error. so you can disable these errors and it will still work.