PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Tue Dec 12, 2017 7:27 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Fri Oct 06, 2017 2:07 pm 
Offline
Forum Newbie

Joined: Fri Oct 06, 2017 1:57 pm
Posts: 2
Hi,

I am new in php and I have a problem a push from your would be no refusal :p, my problem is when I execute the query in sql server its works normaly but when I execute its with php does not work empty result . thanks to helping me

here my code:

Syntax: [ Download ] [ Hide ]

$sql = "  

select t.Tan, SUM(s.TOP) as Top
into #TempEnj
from [Proses].[dbo].[CD_Dok] d
inner join [Proses].[dbo].[CD_Sar] s on(s.DOID = d.ID)
inner join [Proses].[dbo].[CT_Sa] t on (s.TANID= t.ID)

  where d.date ='2017-10-05'

   group by T.Tan

insert into #TempEnj values ('Enerji', (select sum(Enj) from [Proses].[dbo].[CD_Dok] where date ='2017-10-05'))
insert into #TempEnj values ('Sure', (select sum(Sure) from [Proses].[dbo].[CD_Dok] where date ='2017-10-05'))
select * from #TempEnj "
;




$stmt5  sqlsrv_query( $conn, $sql );
if( $stmt == false ) {
    if( ($errors = sqlsrv_errors() ) != null) {
        foreach( $errors as $error ) {
            echo "SQLSTATE: ".$error[ 'SQLSTATE']."<br />";
            echo "code: ".$error[ 'code']."<br />";
            echo "message: ".$error[ 'message']."<br />";
        }
    }
}


$tab[]= array();
while( $row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_ASSOC) ) {
    $tab[] = $row;


}  
var_dump($tab);


 


Top
 Profile  
 
PostPosted: Sat Oct 07, 2017 2:49 am 
Offline
Spammer :|
User avatar

Joined: Wed Oct 15, 2008 2:35 am
Posts: 6602
Location: WA, USA
If sqlsrv_query allows you to run multiple queries then they probably need to be delimited by semicolons, and you'd probably need to use sqlsrv_next_result() to go between the two/four resultsets.


Top
 Profile  
 
PostPosted: Sat Oct 07, 2017 1:22 pm 
Offline
Forum Newbie

Joined: Fri Oct 06, 2017 1:57 pm
Posts: 2
hi,

you are reight , sqlsrv_next_result() fixed my problem thank you :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: Exabot [Bot] and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group