Jump to content

Parse error: parse error, expecting `'{'' in D:\xampplite\htdocs\Peperiksaan\sample code\samplecode2\wda2-winestore\includes\template.inc on line 28


sueirnaa

Recommended Posts

i've got error Parse error: parse error, expecting `'{'' in D:\xampplite\htdocs\Peperiksaan\sample code\samplecode2\wda2-winestore\includes\template.inc on line 28 ..i can't understand ..line 28 is "class winestoreTemplate extends template.inc" as below.Anyone can help me?-----------------------------------------------require_once "db.inc";require_once "template.inc";require_once "winestore.inc";define("P_TITLE", "Hugh and Dave's Online Wines");// An extension of HTML_Template_ITX for the winestore pagesclass winestoreTemplate extends template.inc{ // Class constructor // Loads the winestore.tpl skeleton, and a named page // Sets the page title

Link to comment
Share on other sites

Somehow I don't think class names can have periods (.) in them - do you really have a class named template.inc?

Link to comment
Share on other sites

Somehow I don't think class names can have periods (.) in them - do you really have a class named template.inc?
what about this error? i ve got another errorParse error: parse error in D:\xampplite\htdocs\Login\peperiksaan\add-delete-update\update.php on line 32line 32 is..$query("UPDATE pengawas SET Nama= '$Nama', kp= '$kp', kp1= '$kp1', kp2= '$kp2', Jawatan= '$jawatan', Gred= '$gred', date1= '$lantik1', date2= '$lantik2', date3= '$lantik3', datesah1= '$sah1', datesah2= '$sah2', datesah3= '$sah3', alamat= '$alamat', poskod= '$poskod', notel= '$notel', nofax= '$notelp', nohp1= '$hp' WHERE PengawasID ='$PengawasID'"); or die('Error : ' . mysql_error());
Link to comment
Share on other sites

owh...some one help me find wht is wrong with my code...i want to update the record from the form, but it won't works...it's suppose to be display the data from database in my form php... i dont where's the error...here is the code :<?phpinclude_once ("config.php");if($_GET['update']){$PengawasID = mysql_real_escape_string($_POST['PengawasID']);$Nama = mysql_real_escape_string($_POST['Nama']);$kp = mysql_real_escape_string($_POST['kp']);$kp1 = mysql_real_escape_string($_POST['kp1']);$kp2 = mysql_real_escape_string($_POST['kp2']);$jawatan = mysql_real_escape_string($_POST['Jawatan']);$gred = mysql_real_escape_string($_POST['Gred']);$lantik1 = mysql_real_escape_string($_POST['date1']);$lantik2 = mysql_real_escape_string($_POST['date2']);$lantik3 = mysql_real_escape_string($_POST['date3']);$sah1 = mysql_real_escape_string($_POST['datesah1']);$sah2 = mysql_real_escape_string($_POST['datesah2']);$sah3 = mysql_real_escape_string($_POST['datesah3']);$alamat = mysql_real_escape_string($_POST['alamat']);$poskod = mysql_real_escape_string($_POST['poskod']);$bandar = mysql_real_escape_string($_POST['bandar']);$notel = mysql_real_escape_string($_POST['notel']);$notelp = mysql_real_escape_string($_POST['nofax']);$hp = mysql_real_escape_string($_POST['nohp1']); $query="UPDATE pengawas SET Nama= '$Nama', kp= '$kp', kp1= '$kp1', kp2= '$kp2', Jawatan= '$jawatan', Gred= '$gred', date1= '$lantik1', date2= '$lantik2', date3= '$lantik3', datesah1= '$sah1', datesah2= '$sah2', datesah3= '$sah3', alamat= '$alamat', poskod= '$poskod', notel= '$notel', nofax= '$notelp', nohp1= '$hp' WHERE PengawasID = $PengawasID" or die('Error : ' . mysql_error()); header("Location: update.php?PengawasID=$PengawasID&msg=done"); exit;}?><!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=iso-8859-1" /><title>DBexam</title><style type="text/css"><!--.style1 { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px;}.style2 { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 16px; color: #333333;}--></style></head><body><h2 align="center" class="style2">Kemaskini Maklumat Pengawas </h2><p> <?phpif ($_GET['msg']){ echo "<p style=\"color:#FF0000\"><strong>Your content has been updated!</strong></p>";}$show = "SELECT * FROM Pengawas WHERE PengawasID = '{$_GET['PengawasID']}'";$result = mysql_query($show);while ($show = mysql_fetch_array ($result));{ $PengawasID = $show['PengawasID'];$Nama = $show['Nama'];$kp = $show['kp'];$kp1 = $show['kp1'];$kp2 = $show['kp2'];$jawatan = $show['Jawatan'];$gred = $show['Gred'];$lantik1 = $show['date1'];$lantik2 = $show['date2'];$lantik3 = $show['date3'];$sah1 = $show['datesah1'];$sah2 = $show['datesah2'];$sah3 = $show['datesah3'];$alamat = $show['alamat'];$poskod = $show['poskod'];$bandar = $show['bandar'];$notel = $show['notel'];$notelp = $show['nofax'];$hp = $show['nohp1'];?></p><form action="update.php?update=yes" method="post"><table width="99%" border="0" cellspacing="1" cellpadding="1"> <tr> <th width="34%" class="text" scope="row"><div align="left" class="style1">Nama:</div></th> <td width="66%"> <input name="Nama" type="text" value="<?php echo $Nama?>" /></td> </tr> <tr> <th class="text" scope="row"><div align="left" class="style1">No.Kad Pengenalan :</div></th> <td><input name="kp" type="text" value="<?php echo $kp?>" /> <label> <input name="kp1" type="text" value="<?php echo $kp1?>" /> <input name="kp2" type="text" value="<?php echo $kp2 ?>" /> </label></td> </tr> <tr> <th class="text" scope="row"><div align="left" class="style1">Jawatan : </div></th> <td><input name="jawatan" type="text" value="<?php echo $Jawatan?>" /></td> </tr> <tr> <th class="text" scope="row"><div align="left" class="style1">Gred Jawatan </div></th> <td><label> <input name="gred" type="text" value="<?php echo $Gred?>" /> </label></td> </tr> <tr> <th class="text" scope="row"><div align="left" class="style1">Tarikh dilantik ke jawatan sekarang : </div></th> <td><label> <input name="lantik1" type="text" value="<?php echo $date1?>" /> </label> <label> <input name="lantik2" type="text" value="<?php echo $date2?>" /> </label> <label> <input name="lantik3" type="text" value="<?php echo $date3?>" /> </label></td> </tr> <tr> <th class="text" scope="row"><div align="left" class="style1">Tarikh disahkan ke jawatan sekarang :</div></th> <td><label> <input name="sah1" type="text" value="<?php echo $datesah1?>" /> </label> <label> <input name="sah2" type="text" value="<?php echo $datesah2?>" /> </label> <label> <input name="sah3" type="text" value="<?php echo $datesah3?>" /> </label></td> </tr> <tr> <th class="text" scope="row"><div align="left" class="style1">Alamat tempat bertugas : </div></th> <td><label> <input name="alamat" type="text" value="<?php echo $alamat?>" /> Poskod <input name="poskod" type="text" value="<?php echo $poskod?>" /> Bandar : <input name="bandar" type="text" value="<?php echo $bandar?>" /></label></td> </tr> <tr> <th class="text" scope="row"><div align="left" class="style1">No Telefon Pejabat : </div></th> <td><label> <input name="notel" type="text" value="<?php echo $notel?>" /> </label></td> </tr> <tr> <th class="text" scope="row"><div align="left" class="style1">No Faks Pejabat : </div></th> <td><label> <input name="notelp" type="text" value="<?php echo $nofax?>" /> </label></td> </tr> <tr> <th class="text" scope="row"><div align="left" class="style1">No Telefon Bimbit : </div></th> <td><label> <input name="textfield16" value="<?php echo $nohp1?>" /> </label></td> </tr> <tr> <th scope="row"> </th> <td><input type="submit" name="Submit" value="Update" /> <input type="hidden" value="<?php echo $PengawasID?>" name="PengawasID"> </td> </tr> <tr> <th scope="row"> </th> <td> </td> </tr> <tr> <th scope="row"> </th> <td> </td> </tr> <tr> <th scope="row"> </th> <td> </td> </tr> <tr> <th scope="row"> </th> <td> </td> </tr></table></form><?php}?><p> </p></body></html>

Link to comment
Share on other sites

What happens when you run the code?
when i run the code...cannot show the record in the database...the record should be display in textfield...then when i change the record to update..doesnt works....nothing change.there is no error msg...
Link to comment
Share on other sites

So you see the text field, but it does not update the database?It looks like you're not actually running the query. You build the query, but you don't do anything with it. You need to use mysql_query to send the update query to the database.

Link to comment
Share on other sites

as u can see, this is the code for select Query----------------------------------------------------$show = "SELECT * FROM pengawas WHERE PengawasID = '{$_GET['PengawasID']}'";$result = mysql_query($show);while ($show = mysql_fetch_array ($result));{ // $PengawasID refer to textfield name in the form, ['PengawasID']; refer to colum field in the database. Am i right?$PengawasID = $show['PengawasID'];$Nama = $show['Nama'];$kp = $show['kp'];$kp1 = $show['kp1'];$kp2 = $show['kp2'];$jawatan = $show['Jawatan'];$gred = $show['Gred'];$lantik1 = $show['date1'];$lantik2 = $show['date2'];$lantik3 = $show['date3'];$sah1 = $show['datesah1'];$sah2 = $show['datesah2'];$sah3 = $show['datesah3'];$alamat = $show['alamat'];$poskod = $show['poskod'];$bandar = $show['bandar'];$notel = $show['notel'];$notelp = $show['nofax'];$hp = $show['nohp1'];?>//this is refer to textfield in the form, the data from database should be display<input name="Nama" type="text" value="<?php echo $Nama ?>" />anything wrong with this?

Link to comment
Share on other sites

There's a stray semicolon after the closing bracket of the while statement.

Link to comment
Share on other sites

Then that means there's an error somewhere. The semicolon should not be there. That's not the query I was talking about though, I was referring to the update query. You build the update query but don't execute it.

Link to comment
Share on other sites

Then that means there's an error somewhere. The semicolon should not be there. That's not the query I was talking about though, I was referring to the update query. You build the update query but don't execute it.
plz help me find the error..icant found where is the error...still doesnt worksupdate.php<?phpinclude_once ("config.php");if($_GET['update']){$PengawasID = mysql_real_escape_string($_POST['PengawasID']);$Nama = mysql_real_escape_string($_POST['Nama']);$kp = mysql_real_escape_string($_POST['kp']);$kp1 = mysql_real_escape_string($_POST['kp1']);$kp2 = mysql_real_escape_string($_POST['kp2']);$jawatan = mysql_real_escape_string($_POST['Jawatan']);$gred = mysql_real_escape_string($_POST['Gred']);$lantik1 = mysql_real_escape_string($_POST['date1']);$lantik2 = mysql_real_escape_string($_POST['date2']);$lantik3 = mysql_real_escape_string($_POST['date3']);$sah1 = mysql_real_escape_string($_POST['datesah1']);$sah2 = mysql_real_escape_string($_POST['datesah2']);$sah3 = mysql_real_escape_string($_POST['datesah3']);$alamat = mysql_real_escape_string($_POST['alamat']);$poskod = mysql_real_escape_string($_POST['poskod']);$bandar = mysql_real_escape_string($_POST['bandar']);$notel = mysql_real_escape_string($_POST['notel']);$notelp = mysql_real_escape_string($_POST['nofax']);$hp = mysql_real_escape_string($_POST['nohp1']);$query = mysql_query("UPDATE pengawas SET Nama= '$Nama', kp= '$kp', kp1='$kp1', kp2='$kp2', Jawatan='$jawatan', Gred='$gred', date1='$lantik1', date2= '$lantik2', date3= '$lantik3', datesah1= '$sah1', datesah2= '$sah2', datesah3= '$sah3', alamat= '$alamat', poskod= '$poskod', notel= '$notel', nofax= '$notelp', nohp1= '$hp' WHERE PengawasID = '$PengawasID'")or die('Error : ' . mysql_error()); header("Location: update.php?PengawasID=$PengawasID&msg=done"); exit;}?><!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=iso-8859-1" /><title>DBexam</title><style type="text/css"><!--.style1 { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px;}.style2 { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 16px; color: #333333;}--></style></head><body><h2 align="center" class="style2">Kemaskini Maklumat Pengawas </h2><p> <?phpif ($_GET['msg']){ echo "<p style=\"color:#FF0000\"><strong>Your content has been updated!</strong></p>";}$show = "SELECT * FROM pengawas WHERE PengawasID = '{$_GET['PengawasID']}'";$result = mysql_query($show);while ($show= mysql_fetch_array ($result));{ $PengawasID = mysql_real_escape_string($_POST['PengawasID']);$Nama = mysql_real_escape_string($_POST['Nama']);$kp = mysql_real_escape_string($_POST['kp']);$kp1 = mysql_real_escape_string($_POST['kp1']);$kp2 = mysql_real_escape_string($_POST['kp2']);$jawatan = mysql_real_escape_string($_POST['Jawatan']);$gred = mysql_real_escape_string($_POST['Gred']);$lantik1 = mysql_real_escape_string($_POST['date1']);$lantik2 = mysql_real_escape_string($_POST['date2']);$lantik3 = mysql_real_escape_string($_POST['date3']);$sah1 = mysql_real_escape_string($_POST['datesah1']);$sah2 = mysql_real_escape_string($_POST['datesah2']);$sah3 = mysql_real_escape_string($_POST['datesah3']);$alamat = mysql_real_escape_string($_POST['alamat']);$poskod = mysql_real_escape_string($_POST['poskod']);$bandar = mysql_real_escape_string($_POST['bandar']);$notel = mysql_real_escape_string($_POST['notel']);$notelp = mysql_real_escape_string($_POST['nofax']);$hp = mysql_real_escape_string($_POST['nohp1']);?></p><form action="update.php?update=yes" method="post"> <table width="99%" border="0" cellspacing="1" cellpadding="1"> <tr> <th width="34%" class="text" scope="row"><div align="left" class="style1">Nama:</div></th> <td width="66%"> <input name="name" type="text" id="name" value="<? echo $row['Nama']; ?>"/> </td> </tr> <tr> <th class="text" scope="row"><div align="left" class="style1">No.Kad Pengenalan :</div></th> <td><input name="kp" type="text" value="<?php echo 'kp'?>" /> <label> <input name="kp1" type="text" value="<?php echo 'kp1'?>" /> <input name="kp2" type="text" value="<?php echo '$kp2'?>" /> </label></td> </tr> <tr> <th class="text" scope="row"><div align="left" class="style1">Jawatan : </div></th> <td><input name="jawatan" type="text" value="<?php echo '$Jawatan'?>" /></td> </tr> <tr> <th class="text" scope="row"><div align="left" class="style1">Gred Jawatan </div></th> <td><label> <input name="gred" type="text" value="<?php echo '$Gred'?>" /> </label></td> </tr> <tr> <th class="text" scope="row"><div align="left" class="style1">Tarikh dilantik ke jawatan sekarang : </div></th> <td><label> <input name="lantik1" type="text" value="<?php echo '$date1'?>" /> </label> <label> <input name="lantik2" type="text" value="<?php echo '$date2'?>" /> </label> <label> <input name="lantik3" type="text" value="<?php echo '$date3'?>" /> </label></td> </tr> <tr> <th class="text" scope="row"><div align="left" class="style1">Tarikh disahkan ke jawatan sekarang :</div></th> <td><label> <input name="sah1" type="text" value="<?php echo '$datesah1'?>" /> </label> <label> <input name="sah2" type="text" value="<?php echo '$datesah2'?>" /> </label> <label> <input name="sah3" type="text" value="<?php echo '$datesah3'?>" /> </label></td> </tr> <tr> <th class="text" scope="row"><div align="left" class="style1">Alamat tempat bertugas : </div></th> <td><label> <input name="alamat" type="text" value="<?php echo '$alamat'?>" /> Poskod <input name="poskod" type="text" value="<?php echo '$poskod'?>" /> Bandar : <input name="bandar" type="text" value="<?php echo '$bandar'?>" /></label></td> </tr> <tr> <th class="text" scope="row"><div align="left" class="style1">No Telefon Pejabat : </div></th> <td><label> <input name="notel" type="text" value="<?php echo '$notel'?>" /> </label></td> </tr> <tr> <th class="text" scope="row"><div align="left" class="style1">No Faks Pejabat : </div></th> <td><label> <input name="notelp" type="text" value="<?php echo '$nofax'?>" /> </label></td> </tr> <tr> <th class="text" scope="row"><div align="left" class="style1">No Telefon Bimbit : </div></th> <td><label> <input name="textfield16" value="<?php echo '$nohp1'?>" /> </label></td> </tr> <tr> <th scope="row"> </th> <td><input type="submit" name="Submit" value="Update" /> <input type="hidden" value="<?php echo '$PengawasID'?>" name="PengawasID"> </td> </tr> <tr> <th scope="row"> </th> <td> </td> </tr> <tr> <th scope="row"> </th> <td> </td> </tr> <tr> <th scope="row"> </th> <td> </td> </tr> <tr> <th scope="row"> </th> <td> </td> </tr></table></form><?php}?><p> </p></body></html>
Link to comment
Share on other sites

did you follow Synook's advice? That semicolon is still there, you need to remove it. Just because it causes a blank page doesn't mean that it was the wrong thing to do, clearly there is something else wrong on the page. I would inspect your while statement a bit more, and determine if it properly structured, maybe it has mis-matching opening and closing curly braces...

Link to comment
Share on other sites

did you follow Synook's advice? That semicolon is still there, you need to remove it. Just because it causes a blank page doesn't mean that it was the wrong thing to do, clearly there is something else wrong on the page. I would inspect your while statement a bit more, and determine if it properly structured, maybe it has mis-matching opening and closing curly braces...
yes..i tried to remove the semicolon in While Statement..i ve got error as belowWarning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in D:\xampplite\htdocs\Peperiksaan\sample code\samplecode3\update.php on line 52Line 52 is While Statemant ;open braces i put after while statement then close braces at the last code. i cant understand whts the error means in this code?$show = "SELECT * FROM peperiksaan WHERE PengawasID = '{$_GET['PengawasID']}'";$result = mysql_query($show);while ($show = mysql_fetch_array ($result)){ $PengawasID = $show[PengawasID]; $Nama = $show[Nama]; $kp = $show[kp]; $kp1 = $show[kp1]; $kp2 = $show[kp2]; $jawatan = $show[Jawatan]; $gred = $show[Gred]; $lantik1 = $show[date1]; $lantik2 = $show[date2]; $lantik3 = $show[date3]; $sah1 = $show[datesah1]; $sah2 = $show[datesah2]; $sah3 = $show[datesah3]; $alamat =$show[alamat]; $poskod = $show[poskod]; $bandar = $show[bandar]; $notel = $show[notel]; $notelp = $show[nofax]; $hp = $show[nohp1];?><form action="update.php?update=yes" method="post"><table width="50%" border="0" cellspacing="1" cellpadding="1"> <tr> <th scope="row"><div align="right">Nama:</div></th> <td><input name="Nama" type="text" id="Nama" value="<?php echo $Nama; ?>" /></td> </tr> <tr> <th scope="row"><div align="right">kp:</div></th> <td><textarea name="kp" cols="50" rows="7" id="kp"><?php echo $kp; ?></textarea></td> </tr> <tr> <th scope="row"> </th> <td><input type="submit" name="Submit" value="Update" /> <input type="hidden" name="PengawasID" value="<?php echo $PengawasID; ?>"/></td> </tr></table></form><?php}?><p> </p></body></html>
Link to comment
Share on other sites

You have to close the while statement when it ends, not at the end of the page; after $hp = $show[nohp1]; but before ?>.

Link to comment
Share on other sites

You have to close the while statement when it ends, not at the end of the page; after $hp = $show[nohp1]; but before ?>.
i 've tried but got error. Then i changed the query SELECT like this $show = "SELECT * FROM pengawas";seems ok.. records appear in the textfield... and something wrong with my update query...not execute it.justsomeguy: Plz check for me... I have been for days but did not make it rightHere is my file : http://www.4shared.com/file/k84RGOQd/sharephp.html
Link to comment
Share on other sites

i 've tried but got error.
did you make sure to end it with a semicolon? you should just post the PHP code.
Link to comment
Share on other sites

I can't print your database error, the database is on your computer.
ok..here is my tabledb_name : peperiksaantable_name :pengawasfield : PengawasID Int(11),auto increment Nama varchar(50) KP varchar(12),primary key Jawatan text Gred Int(11) Tlantik text Tsah text alamat text poskod Int(11) bandar text notel Int(11) nofax Int(11) nohp1 Int(15)my php code..there are 3 files phpconfig.php<?php define('DB_HOST', 'localhost'); define('DB_USER', 'root'); define('DB_PASSWORD', 'xxxxx'); define('DB_DATABASE', 'peperiksaan');$connect = mysql_connect(localhost, root, xxxxx) or die("Cannot connect to the database");mysql_select_db(peperiksaan) or die("Cannot select the database");?>view.php<?phpinclude_once ("config.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=iso-8859-1" /><title>Untitled Document</title><style type="text/css"><!--.style1 {font-family: Verdana, Arial, Helvetica, sans-serif}.style5 {color: #FFFFFF; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; }.text { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; font-style: normal; font-weight: normal; color: #333333;}--></style></head><body><h2 align="center" class="style1">Maklumat Pengawas </h2><p> </p><table width="96%" border="0" cellspacing="1" cellpadding="1"> <tr> <th width="18%" bgcolor="#333300"><div align="left" class="style5">Nama</div></th> <th width="17%" bgcolor="#333300"><div align="left" class="style5">No.Kad Pengenalan </div></th> <th width="26%" bgcolor="#333300"><div align="left" class="style5">Jawatan</div></th> <th width="13%" bgcolor="#333300"><div align="left" class="style5">Gred </div></th> <th width="15%" bgcolor="#333300"><div align="left" class="style5">Alamat bertugas </div></th> <th width="11%" bgcolor="#333300"><div align="left" class="style5">Update</div></th> </tr></table><?php$show = "SELECT * FROM pengawas ORDER BY Nama ASC";$result = mysql_query($show);while ($show = mysql_fetch_array ($result)){ //$PengawsID= $show[PengawasID]; $Nama= $show[Nama]; $KP= $show[KP]; $Jawatan= $show[Jawatan]; $Gred= $show[Gred]; $alamat=$show[alamat]; ?><table width="97%" border="0" cellpadding="1" cellspacing="1" class="text"> <tr> <td width="18%"><p align="left"><?php echo $Nama; ?></p></td> <td width="17%"><p align="left"><?php echo $KP; ?></p></td> <td width="25%"><p align="left"><?php echo $Jawatan; ?></p></td> <td width="13%"><p align="left"><?php echo $Gred; ?></p></td> <td width="15%"><p align="left"><?php echo $alamat; ?></p></td> <td width="12%"><p align="left"><a href="update.php?PengawasID=<?php echo $PengawasID; ?>">Update</a></p></td> </tr></table><?php}?><p> </p></body></html>update.php<?phpinclude_once ("config.php");if($_GET['update']){$PengawasID = mysql_real_escape_string($_POST['PengawasID']);$Name = mysql_real_escape_string($_POST['Nama']);$kp = mysql_real_escape_string($_POST['KP']);$jawatan = mysql_real_escape_string($_POST['Jawatan']);$gred = mysql_real_escape_string($_POST['Gred']);$lantik1 = mysql_real_escape_string($_POST['Tlantik']);$sah1 = mysql_real_escape_string($_POST['Tsah']);$alamat = mysql_real_escape_string($_POST['alamat']);$poskod = mysql_real_escape_string($_POST['poskod']);$bandar = mysql_real_escape_string($_POST['bandar']);$notel = mysql_real_escape_string($_POST['notel']);$notelp = mysql_real_escape_string($_POST['nofax']);$hp = mysql_real_escape_string($_POST['nohp1']);$query = mysql_query("UPDATE pengawas SET `Nama`= '$Name', `kp`= '$KP',`Jawatan`='$jawatan', `Gred`='$gred', `Tlantik`='$lantik1', `Tsah`= '$sah1',`alamat`= '$alamat', `poskod`= '$poskod', `notel`= '$notel', `nofax`= '$notelp', `nohp1`= '$hp'")or die('Error : ' . mysql_error()); header("Location: update.php?PengawasID=$PengawasID&msg=done"); exit;}?><!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=iso-8859-1" /><title>DBexam</title><style type="text/css"><!--.style1 { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px;}.style2 { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 16px; color: #333333;}--></style></head><body><h2 align="center" class="style2">Kemaskini Maklumat Pengawas </h2><p><?phpif ($_GET['msg']){ echo "<p style=\"color:#FF0000\"><strong>Your content has been updated!</strong></p>";}//SELECT columns FROM table_name [WHERE condition] [ORDER BY order_type] [LIMIT limit_criteria];$show = "SELECT * FROM pengawas WHERE PengawasID='$_GET[PengawasID]'";$result = mysql_query($show);while ($show = mysql_fetch_array ($result)){$PengawasID = $show[PengawasID];$Name = $show[Nama];$kp = $show[KP];$jawatan = $show[Jawatan];$gred = $show[Gred];$lantik1 = $show[Tlantik];$sah1 = $show[Tsah];$alamat =$show[alamat];$poskod = $show[poskod];$bandar = $show[bandar];$notel = $show[notel];$notelp = $show[nofax];$hp = $show[nohp1];}?><form action="update.php?update=yes" method="post"> <table width="99%" border="0" cellspacing="1" cellpadding="1"> <tr> <th width="34%" class="text" scope="row"><div align="left" class="style1">Nama:</div></th> <td width="66%"> <input name="name" type="text" id="name" value="<?php echo $Nama; ?>"/> </td> </tr> <tr> <th class="text" scope="row"><div align="left" class="style1">No.Kad Pengenalan :</div></th> <td><input name="kp" type="text" value="<?php echo $KP; ?>" /> <label></label></td> </tr> <tr> <th class="text" scope="row"><div align="left" class="style1">Jawatan : </div></th> <td><label> <input name="jawatan" type="text" id="jawatan" value="<?php echo $Jawatan;?>" /> </label></td> </tr> <tr> <th class="text" scope="row"><div align="left" class="style1">Gred Jawatan </div></th> <td><label> <input name="gred" type="text" value="<?php echo $Gred;?>" /> </label></td> </tr> <tr> <th class="text" scope="row"><div align="left" class="style1">Tarikh dilantik ke jawatan sekarang : </div></th> <td><label> <input name="lantik1" type="text" value="<?php echo $Tlantik;?>" /> </label> <label></label> <label></label></td> </tr> <tr> <th class="text" scope="row"><div align="left" class="style1">Tarikh disahkan ke jawatan sekarang :</div></th> <td><label> <input name="sah1" type="text" value="<?php echo $Tsah;?>" /> </label> <label></label> <label></label></td> </tr> <tr> <th class="text" scope="row"><div align="left" class="style1">Alamat tempat bertugas : </div></th> <td><label> <input name="alamat" type="text" value="<?php echo $alamat;?>" /> Poskod <input name="poskod" type="text" value="<?php echo $poskod;?>" /> Bandar : <input name="bandar" type="text" value="<?php echo $$bandar;?>" /></label></td> </tr> <tr> <th class="text" scope="row"><div align="left" class="style1">No Telefon Pejabat : </div></th> <td><label> <input name="notel" type="text" value="<?php echo $notel;?>" /> </label></td> </tr> <tr> <th class="text" scope="row"><div align="left" class="style1">No Faks Pejabat : </div></th> <td><label> <input name="notelp" type="text" value="<?php echo $nofax;?>" /> </label></td> </tr> <tr> <th class="text" scope="row"><div align="left" class="style1">No Telefon Bimbit : </div></th> <td><label> <input name="textfield16" value="<?php echo $nohp1;?>" /> </label></td> </tr> <tr> <th scope="row"> </th> <td><input type="submit" name="Submit" value="Update" /> <input type="hidden" value="<?php echo $PengawasID; ?>" name="PengawasID"> </td> </tr> <tr> <th scope="row"> </th> <td> </td> </tr> <tr> <th scope="row"> </th> <td> </td> </tr> <tr> <th scope="row"> </th> <td> </td> </tr> <tr> <th scope="row"> </th> <td> </td> </tr></table></form><p> </p></body></html>plz i need help!
Link to comment
Share on other sites

Are you getting any new errors? Still the same one?it looks like some of your while statements still aren't closed. That should be fixed first. If you're trying to output HTML while in while loop you need to use something like echo and keep it all within the <?php ?>

Link to comment
Share on other sites

Are you getting any new errors? Still the same one?it looks like some of your while statements still aren't closed. That should be fixed first. If you're trying to output HTML while in while loop you need to use something like echo and keep it all within the <?php ?>
thescientist: while statement not closed? emm I'm not understand, i cannot get you what you are saying.. you better make an example coding so that i can understand.
Link to comment
Share on other sites

just look in your code. view.php. The first while statement. It's not closed. Then you output a table that includes a PHP variable but it's not within PHP tags, and not written using the proper syntax of using PHP to write HTML.

Link to comment
Share on other sites

The view.php looks fine, the while loop closes after the table. I'm not sure where we are at this point, are there any errors? For the config file, you're defining constants for your connection information but then you don't use them. When you connect you're trying to use the information directly, but it's not quoted. Just use the constants you just defined. Also specify the error reporting to make sure you're seeing all error messages:

<?phpini_set('display_errors', 1);error_reporting(E_ALL);define('DB_HOST', 'localhost');define('DB_USER', 'root');define('DB_PASSWORD', 'xxxxx');define('DB_DATABASE', 'peperiksaan');$connect = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD) or die("Cannot connect to the database");mysql_select_db(DB_DATABASE) or die("Cannot select the database");?>

When you have lines like this:$PengawasID = $show[PengawasID];That's not correct. That is telling PHP to look for an item in the array show where the name of the index is in the constant PengawasID. But PengawasID is not the name of a constant, it's the name of the item you're looking for. So it needs to go in quotes:$PengawasID = $show['PengawasID'];

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...