简体   繁体   中英

update doesn't work

I've been trying to update a table in my database triggered by an UPDATE button but somehow it doesn't work, whenever I change the values then click the update button, it just refreshes the values, no update/change happens..please help

<?php
session_start();
require_once("dbconnect.php");

$webhost=$_GET["webhost"];

$requesttitle=$_POST["requesttitle"];
$requesturl=$_POST["requesturl"];
$requestcap=$_POST["requestcap"];
$requestdestype=$_POST["requestdestype"];
$requestdbtype=$_POST["requestdbtype"];
$deptname=$_POST["deptname"];
$contactname=$_POST["contactname"];
$contactnum=$_POST["contactnum"];
$contactemail=$_POST["contactemail"];
$startdate=$_POST["startdate"];
$enddate=$_POST["enddate"];

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

$sql="update webhostrequest set requesttitle='$requesttitle', ";
    $sql.="requesturl='$requesturl', requestcap='$requestcap', ";
    $sql.="requestdestype='$requestdestype', requestdbtype='$requestdbtype', ";
    $sql.="deptname='$deptname', contactname='$contactname', ";
    $sql.="contactnum='$contactnum', contactemail='$contactemail' ';
    $sql.="startdate='$startdate',  enddate='$enddate', recentact=now() where requestid='$id'";

$result = mysql_query($sql) or die ("Error in editing item. ".mysql_error());
}
header("location: editwebhost.php?webhost=$webhost");
exit;

?>

$id is not set in your code. So as the "WHERE" stipulates only update the entry with requestid =$id, it's probably the missing link?

Try echoing $sql to the page so you can see what query your code is producing. Then try running the query directly (through phpMyAdmin or however you access your db).

Are you getting any error from your "or die()"?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM