PHP Aggghhh
| From: | David Elliott | Date: | Fri, 19 Jul 2002 19:10:43 +0000 |
| Subject: | PHP Aggghhh | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-14849@lists.php.net to get a copy of this message | ||
Salutation all,
Dear all,
a bit of a long post.
System
W2K server
MS SQL 2000
PHP 4.2.1 (in CGI mode)
I want to run a query to populate 5 tables inside a single transaction. it
looks something like.
==========8<=============================================================
$ExcQry = "
begin transaction
set nocount on
declare
@PerID int
,@ConID int
,@BilID int
,@DelId int
insert into
Item (ItemTypeid,Name,LastUpdated,LegacyId)
Values(42,'$client[CCompanyName]',Current_timestamp,'".date
("mdGis")."')
set @PerId = @@identity
insert into
Item (ItemTypeid,Name,LastUpdated,LegacyId)
Values(42,'$client[DCompanyName]',Current_timestamp,'".date
("mdGis")."')
set @ConId = @@identity
insert into
Item (ItemTypeid,Name,LastUpdated,LegacyId)
Values(42,'$client[DCompanyName]',Current_timestamp,'".date
("mdGis")."')
set @DelID = @@identity
insert into
Item (ItemTypeid,Name,LastUpdated,LegacyId)
Values(42,'$client[BCompanyName]',Current_timestamp,'".date
("mdGis")."')
set @BilID = @@identity
insert into
person
(ItemId,CompanyName,FirstName,LastName,Dear,TitleID,EmailAddress,Phone1,Phone2,Fax,PWord
,PwordPhrase,VatNO,ContID,BillID,DeliID,DistId)
Values
(@PerId,'$client[PCompanyName]','$client[PFirstName]','$client[PLastName]'
,'$client[PDear]','$client[PTitleID]','$client[PEmail]','$client[PPhone1]','$client[PPhone2]'
,'$client[PFax]','$client[PPWord]','$client[PPwordPhrase]','$client[PVatNO]'
,@ConId,@BilId,@DelId,'$client[BDistId]')
set nocount off
commit
select @PerId itemid
";
$Result = mssql_query($ExcQry) or die (DispDBErr($ExcQry1));
list($ItemId)=mssql_fetch_row($result);
@mssql_free_result($result);
$ExcQry1 = "select ContId,BillId,DeliId from person where ItemId =
'".$ItemId."'";
$Result1 = mssql_query($ExcQry1) or die (DispDBErr($ExcQry1));
==========8<=============================================================
The first one works but does not send back a result set. The second one does
not even get posted.
If I omit the [select @PerId itemid] from first query the next query
whatever it does not get called.
The result page look like
Warning: mssql_fetch_row(): supplied argument is not a valid MS SQL-result
resource in D:\Data\Work\wwwroot\Tocris\shop\_include\clientlib.php on line
278
Warning: MS SQL: Query failed in
D:\Data\Work\wwwroot\Tocris\shop\_include\clientlib.php on line 284
--------------------------------------------------------------------------------
The Query
--------------------------------------------------------------------------------
select ContId,BillId,DeliId from person where ItemId = ''
--------------------------------------------------------------------------------
Gave this error
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
What am i doing wrong.
--
HAND, _______________________________________________
David | David Elliott | Software Engineer |
_________________________| list@elliott.uk.com | PGP Key ID 0x650F4534 |
| Yo'momma so ugly for Halloween she trick or treats on the phone! |