hello. please help me.. my code <?php session_start();?> member.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <form id="form1" method="post" action="updateMember.php"> <table width="779" border="0" align="center" bgcolor="#FFFFFF"> <tr> <?php $db = mysql_connect("localhost","root") or die ("Could Not Connect to Server" . mysql_error()); /* select database */ mysql_select_db("ppk4a", $db) or die ("Could Not Connect to Server" . mysql_error()); $id = $_SESSION['id']; $result = mysql_query("SELECT * from member WHERE id='$id'"); $matched = mysql_fetch_array($result); echo '<td width="380">Name</td>'; echo '<td width="8">:</td>'; echo '<td width="369"><label>'; echo '<input type="text" name="name" id="name" size="60" value="'.$matched['name'].'" DISABLED />'; ?> </label></td> </tr> <tr> <td>ID Number</td> <td>:</td> <td><?php echo '<input type="text" name="id" id="id" size="60" value="'.$matched['id'].'"/></td>'; mysql_close($db); ?> </tr> <tr> <td>Are you work</td> <td>:</td> <td><label> <select name="select3" id="select3"> <option value="Work">Work</option> <option value="Not work">Not work</option> <option value="Retired">Retired</option> <option value="Own Business">Own Business</option> </select> </label></td> </tr> <tr> <td>Profession </td> <td>:</td> <td><?php echo '<input type="text" name="profession " id="profession " size="60" value="'.$matched['profession'].'"/></td>'; mysql_close($db); ?> </tr> <input type="submit" name="button" id="button" value="Save" /> </form> </body> </html> updateMember.php <?php session_start();?> <?php $id = $_SESSION['id']; $work = $_POST['select3']; $profession = $_POST['profession ']; $db = mysql_connect("localhost","root") or die ("Could Not Connect to Server" . mysql_error()); /* select database */ mysql_select_db("ppk4a", $db) or die ("Could Not Connect to Server" . mysql_error()); $query = "UPDATE member SET work='$work', profession='$profession' WHERE id ='$id'"; mysql_query($query) or die(mysql_error()); if($query) { echo("<SCRIPT LANGUAGE='JavaScript'> window.alert('Information Save') </SCRIPT>"); echo "<script language='Javascript'>navigate('home.php')</script>"; exit(); } mysql_close($db); ?> my work is for fill up the information for member that live in one community.they must go to office to register to administrator by name and id. after that they must fill up the form by online. so, by my coding first they open their form, their name and id already have. but they must fill up for the work and profession. when user choose for select 3 between work, not work, retired or own business. if the user select not work the field for profession is not must to fill. but went user get a work they must update their information. my problem, when user want to update their information for second time, like change not work to work and fill the profession it does not work. the error is "Query was empty" so how can i do that?? it is problem in my database?
You need to check the code here echo '<input type="text" name="profession " id="profession " size="60" value="'.$matched['profession'].'"/></td>'; Code (markup): and here $profession = $_POST['profession ']; Code (markup): You have empty spaces all over the place, remove them and you should be fine aXe
i have another question... <td><script language="javascript" type="text/javascript" src="datetimepicker.js"></script> <?php echo '<input id="sara" name="sara" type="text" size="10" value="'.$matched['tarikh_sara'].'"/>'; ?> <a href="javascript:NewCal('sara','ddmmyyyy')"><img src="images/cal.gif" width="16" height="16" border="0" alt="Pick a date"></a></td> $sara = $_POST ['sara']; $query = "UPDATE penduduk SET status_kahwin='$statusKahwin', kerja='$kerjaan', alamat_kerja='$alamatPej', gaji='$gaji', tel_rmh='$telRumah', tel_hp='$telHP', tel_pej='$telPej', status_rumah='$statusRumah', boolean_kerja='$kerja', kategori_kerja='$sektor', tarikh_sara='$sara', pencen_bulan='$pencen', pndptn_akhir='$akhir', oku='$oku' WHERE penduduk_kp='$kp'"; i want the value of date update to database?? another data i will update it. but for this, it cannot. Why?