|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2002-08-29 17:24 UTC] georg@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 22:00:01 2025 UTC |
This is a script of a form: Mssql tables create by the sentence: create table LU_CO_VIP_CLASS( id int IDENTITY (1, 1) NOT NULL, vip_class int null, class_sum_max varchar(32) null, class_sum_min varchar(32) null, class_rebate int null ) Php program: <? $class=$HTTP_POST_VARS['class']; $rebate=$HTTP_POST_VARS['rebate']; $costmin=$HTTP_POST_VARS['costmin']; $costmax=$HTTP_POST_VARS['costmax']; $id=mssql_connect("localhost","sa","admin") or die("CAN NOT CONNECT"); $db=mssql_select_db("netpass_bak",$id); if (!empty($class) and !empty($rebate) and !empty($costmin) and !empty($costmax)) { $query="if exists (select * from LU_CO_VIP_CLASS where vip_class=$class) begin update LU_CO_VIP_CLASS set class_rebate=$rebate, class_sum_min='$costmin', class_sum_max='$costmax' where vip_class=$class end else insert into LU_CO_VIP_CLASS ( vip_class, class_sum_max, class_sum_min, class_rebate) VALUES ( $class, $costmax, $costmin, $rebate)"; mssql_query($query); } $query="select * from LU_CO_VIP_CLASS order by vip_class"; $result=mssql_query($query); //line 78 echo "<font size=5 color=#0000FF><b>CLASS</font></b><br>"; echo "<table width=100% border=1 bordercolor=#FFFFFF cellpadding=1 cellspacing=1><tr bgcolor=#6699FF>"; echo "<td><font size=2>CLASS</font></td>"; echo "<td><font size=2 width=30%>MAX</font></td>"; echo "<td><font size=2>MIN</font></td>"; echo "<td><font size=2>REBATE</font></td></tr>"; while ($arrGuest=mssql_fetch_array($result)) { echo "<tr>"; echo "<td bgcolor=#66CCFF><font size=2>".$arrGuest["vip_class"]."</font></td>"; echo "<td bgcolor=#66CCFF><font size=2 width=30%>$".$arrGuest["class_sum_max"]."</font></td>"; echo "<td bgcolor=#66CCFF><font size=2>$".$arrGuest["class_sum_min"]."</font></td>"; echo "<td bgcolor=#66CCFF><font size=2>".$arrGuest["class_rebate"]."%</font></td>"; echo "</tr>"; } echo "</table>"; ?> The error:MS SQL: Query failed in e:\php\vipclass.php on line 78.(database had been modifyed successfully) But when I cut the segment:" if exists (select * from LU_CO_VIP_CLASS where vip_class=$class) begin update LU_CO_VIP_CLASS set class_rebate=$rebate, class_sum_min='$costmin', class_sum_max='$costmax' where vip_class=$class end else " (only inset into) or cut the segment of insert into(only update) ,it's display right. Is it a bug?