PDA

View Full Version : update script for my mysql database


razaksamad
05-07-2008, 06:32 AM
Hi,I am trying to create an update script for my mysql database but cant get the thing to work


Heres the mysql update script (edit_masuk.php):



include("include_cari.php");

if(isset($_POST['Submit'])){

$id = $_REQUEST['id'];
$name = $_REQUEST['name'];


$sql = "UPDATE alumni SET name = '" . $name . "' WHERE id = '" . $id . "'";
$query = mysql_query($sql);

if ($query) {
header("location:display_cari.php");
exit;
}
}

$id = $_REQUEST['id'];

$result=mysql_query("select * from alumni where id='$id'");

$row=mysql_fetch_assoc($result);

abduraooft
05-07-2008, 09:31 AM
Please read this sticky before posting your code here, http://www.codingforums.com/showthread.php?t=68462

Are you getting any error? If not make sure that the error reporting is turned on. Also, execute your queries like
mysql_query("your query here") or die(mysql_error());

PS: Instead of using $_REQUEST array, use specific $_GET, $_POST etc to retrieve the values.