php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #19173 "mssql_query" error
Submitted: 2002-08-29 10:23 UTC Modified: 2002-08-29 17:24 UTC
From: luchuoyu at hotmail dot com Assigned:
Status: Not a bug Package: MSSQL related
PHP Version: 4.2.2 OS: windows 2000 server
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: luchuoyu at hotmail dot com
New email:
PHP Version: OS:

 

 [2002-08-29 10:23 UTC] luchuoyu at hotmail dot com
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? 

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-08-29 17:24 UTC] georg@php.net
Sorry, but the bug system is not the appropriate forum for asking
support questions. Your problem does not imply a bug in PHP itself.
For a list of more appropriate places to ask for help using PHP,
please visit http://www.php.net/support.php

Thank you for your interest in PHP.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 17:01:58 2024 UTC