php/mysql,页面提交后脚本提示成功,但数据库却没有真正的更新。
<?phpinclude("config.php");$memberID=$_POST["memberID"];//这个memberID是readonly的,所以作为sq...
<?php
include("config.php");
$memberID = $_POST["memberID"]; //这个memberID是readonly的,所以作为sql语句的判断依据
$CategoryName=$_POST["CategoryName"];
$Rank=$_POST["Rank"];
$FirstName=$_POST["FirstName"];
$LastName=$_POST["LastName"];
$Suffix=$_POST["Suffix"];
$Address=$_POST["Address"];
$City=$_POST["City"];
$StateOrProvince=$_POST["StateOrProvince"];
$PostalCode=$_POST["PostalCode"];
$Country=$_POST["Country"];
$EmailAddress=$_POST["EmailAddress"];
$HomePhone=$_POST["HomePhone"];
$MobilePhone1=$_POST["MobilePhone1"];
$WorkPhone=$_POST["WorkPhone"];
$WorkExtension=$_POST["WorkExtension"];
$FaxNumber=$_POST["FaxNumber"];
$Notes=$_POST["Notes"];
$db=mysql_connect($servername,$sqlservername,$sqlserverpws);
mysql_select_db($sqlname,$db) ;
$sql="UPDATE $sqltable
SET CategoryName=$CategoryName, Rank=$Rank, FirstName=$FirstName, LastName=$LastName, Suffix=$Suffix, Address=$Address, City=$City, StateOrProvince=$StateOrProvince, PostalCode=$PostalCode, Country=$Country,EmailAddress=$EmailAddress, HomePhone=$HomePhone, MobilePhone1=$MobilePhone1, WorkPhone=$WorkPhone, WorkExtension=$WorkExtension, FaxNumber=$FaxNumber, Notes=$Notes
WHERE memberID = '$memberID'";
mysql_query($sql);
echo ("<script type='text/javascript'> alert('Update Successfully.');location.href='add_new.php';</script>");
?> 展开
include("config.php");
$memberID = $_POST["memberID"]; //这个memberID是readonly的,所以作为sql语句的判断依据
$CategoryName=$_POST["CategoryName"];
$Rank=$_POST["Rank"];
$FirstName=$_POST["FirstName"];
$LastName=$_POST["LastName"];
$Suffix=$_POST["Suffix"];
$Address=$_POST["Address"];
$City=$_POST["City"];
$StateOrProvince=$_POST["StateOrProvince"];
$PostalCode=$_POST["PostalCode"];
$Country=$_POST["Country"];
$EmailAddress=$_POST["EmailAddress"];
$HomePhone=$_POST["HomePhone"];
$MobilePhone1=$_POST["MobilePhone1"];
$WorkPhone=$_POST["WorkPhone"];
$WorkExtension=$_POST["WorkExtension"];
$FaxNumber=$_POST["FaxNumber"];
$Notes=$_POST["Notes"];
$db=mysql_connect($servername,$sqlservername,$sqlserverpws);
mysql_select_db($sqlname,$db) ;
$sql="UPDATE $sqltable
SET CategoryName=$CategoryName, Rank=$Rank, FirstName=$FirstName, LastName=$LastName, Suffix=$Suffix, Address=$Address, City=$City, StateOrProvince=$StateOrProvince, PostalCode=$PostalCode, Country=$Country,EmailAddress=$EmailAddress, HomePhone=$HomePhone, MobilePhone1=$MobilePhone1, WorkPhone=$WorkPhone, WorkExtension=$WorkExtension, FaxNumber=$FaxNumber, Notes=$Notes
WHERE memberID = '$memberID'";
mysql_query($sql);
echo ("<script type='text/javascript'> alert('Update Successfully.');location.href='add_new.php';</script>");
?> 展开
展开全部
你提示成功的那句话和你数据库操作根本没关联在一起,当然会每次都提示成功了。数据库操作失败的原因是你的SQL语句中,没有给变量加上单引号。虽然你平时在双引号中使用PHP变量加不加单引号都没关系,但是在SQL语句中不加引号是会产生错误的。将你的SQL语句修改下就应该没问题了。如果修改后还不行,那么你就要检查下你的数据库连接参数是否正确了。
追问
sql语句这么改
SET CategoryName=‘$CategoryName’, Rank=‘$Rank’, FirstName=‘$FirstName’, ……
另外echo语句的关联是指
写成if {$sql=xxx },echo
这样对么
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询