473,399 Members | 2,858 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Php output differnt than MSSQL

5
Hey, I have a really confusing problem here.

I'm using MSSQL & PHP. I have created a querry in MSSQL that basically shows a list of events and shows them in date order. I have written a bit of code into the mssql statement that says 'If the current date is the friday before the event date, and the event date is on a saturday or sunday, then dont show that event'

when I run that code in mssql it returns the correct results - when its firday the next event it shows is a monday (as it should).

However when i then run this querry in php it does not show the desired results.

For example when php ran this on saturday it showed events for saturday & sunday (when it should show monday onwards). and when running it today it shows events for tuesday (when it should be showing events for monday as well)

My select statement is quite massive so appologies if its confusing

Expand|Select|Wrap|Line Numbers
  1. SELECT DISTINCT 
  2.                       dbo.events.showPrice, dbo.events.eventID, dbo.events.categoryID, dbo.events.eventName, dbo.events.eventDetails, dbo.events.eventLive, 
  3.                       dbo.eventCategories.categoryName, eventCategories_1.categoryName AS categoryParent, dbo.events.enabled, tickets_1.ticketStartDate, 
  4.                       MIN(tickets_1.ticketPrice) AS priceFrom, dbo.venues.venueID, dbo.venues.venueName, dbo.venues.venueAddress1, dbo.venues.venueCity, 
  5.                       dbo.venues.venueCounty, dbo.texts.text, '1' AS test,
  6.                           (SELECT     MIN(ticketStartDate) AS minStart
  7.                             FROM          dbo.tickets
  8.                             WHERE      (eventID = 184) AND (ticketStartDate > CASE WHEN Datepart(dw, getdate()) <= 6 AND ticketEndDate > getdate() AND 
  9.                                                    ticketEndDate < DATEADD(DAY, 2, GETDATE()) THEN getDate() ELSE DATEADD(DAY, 2, GETDATE()) END)) AS minStart,
  10.                           (SELECT     MAX(ticketStartDate) AS maxEnd
  11.                             FROM          dbo.tickets AS tickets_2
  12.                             WHERE      (eventID = 184) AND (ticketStartDate > GETDATE())) AS maxEnd
  13. FROM         dbo.events INNER JOIN
  14.                       dbo.eventCategories ON dbo.events.categoryID = dbo.eventCategories.categoryID LEFT OUTER JOIN
  15.                       dbo.eventCategories AS eventCategories_1 ON dbo.eventCategories.categoryParent = eventCategories_1.categoryID INNER JOIN
  16.                       dbo.tickets AS tickets_1 ON dbo.events.eventID = tickets_1.eventID LEFT OUTER JOIN
  17.                       dbo.venues ON tickets_1.venueID = dbo.venues.venueID LEFT OUTER JOIN
  18.                       dbo.texts ON tickets_1.textsID = dbo.texts.textsID
  19. WHERE     (tickets_1.ticketEndDate > CASE WHEN Datepart(dw, getdate()) <= 6 AND tickets_1.ticketEndDate > getdate() AND 
  20.                       tickets_1.ticketEndDate < DATEADD(DAY, 2, GETDATE()) THEN getDate() ELSE DATEADD(DAY, 2, GETDATE()) END)
  21. GROUP BY dbo.events.eventID, dbo.events.categoryID, dbo.events.eventName, dbo.events.eventDetails, dbo.events.eventLive, dbo.events.showPrice, 
  22.                       dbo.eventCategories.categoryName, eventCategories_1.categoryName, tickets_1.ticketEndDate, dbo.events.enabled, tickets_1.ticketStartDate, 
  23.                       dbo.venues.venueName, dbo.venues.venueID, dbo.venues.venueAddress1, dbo.venues.venueCity, dbo.venues.venueCounty, dbo.texts.text
  24. HAVING      (dbo.events.eventID = 184) AND (dbo.events.enabled = 1) AND (MONTH(tickets_1.ticketStartDate) = MONTH(GETDATE())) AND 
  25.                       (YEAR(tickets_1.ticketStartDate) = YEAR(GETDATE()))
  26.  
My initial thinking is maybe the date is wrong in php? iis? or mssql?

What do you think?

Thanks so much in advance
Jul 12 '09 #1
3 2092
Atli
5,058 Expert 4TB
Hi.

I'm sorry to say that I can't really spot a problem with that.
The query you posted contains no variables passed into it by PHP, which pretty much eliminates PHP as the problem.

It doesn't sound likely that your HTTP server (IIS I assume?) is the reason either, as it shouldn't have anything to do with the database connection.

Which just leaves the database connection itself.

Could you show us the code you use to connect to the database and execute the query?
Perhaps we can spot something out of the ordinary.
Jul 15 '09 #2
code green
1,726 Expert 1GB
Hi Atli. This had me stumped also and 75% of my DB stuff is mssql.
The only time I have had a similar effect is across different servers and timezones without realising a few hours difference round midnight was changing the date
Jul 15 '09 #3
tiptap
5
Thanks for the help so far.

Below is the code i run;

Expand|Select|Wrap|Line Numbers
  1. $eventsDetail = $detail->eventsGetTheatreDates($itemID,0,0);
  2.  
  3. print_r($eventsDetail);
  4.  
  5.  
which calls

Expand|Select|Wrap|Line Numbers
  1. public function eventsGetTheatreDates($itemID,$month,$year){
  2.  
  3.             global $db;
  4.  
  5.             $rs = $db->databaseQuery('exec eventsGetTheatreDates '.$itemID.','.$month.','.$year);
  6.             $row = $db->databaseResult($rs);
  7.  
  8.             $db->databaseDisconnect();
  9.  
  10.             return $row;
  11.     }    
  12.  
Which calls

Expand|Select|Wrap|Line Numbers
  1. public function databaseQuery($query)
  2.     {        
  3.         $results = odbc_exec($this->conn,$query);
  4. }
  5.  
  6. public function databaseResult($rs)
  7.     {
  8.         $i = 0;
  9.         $j = 0;
  10.         $arrayTemp = "";
  11.         $arrayItem = "";
  12.         $arrayReturn = "";
  13.         $array = "";
  14.         $arrayReturn["oneRow"] = TRUE;
  15.  
  16.         while(odbc_fetch_row($rs))
  17.         {            
  18.  
  19.             for ($j = 1; $j <= odbc_num_fields($rs); $j++)
  20.             {       
  21.                  $field_name = odbc_field_name($rs, $j);
  22.                  $arrayItem[$field_name] = odbc_result($rs, $field_name);
  23.                  $arrayReturn[$field_name] = odbc_result($rs, $field_name);
  24.  
  25.             }
  26.  
  27.             $array[$i] = $arrayItem;
  28.             $i++;
  29.         }
  30.  
  31.         if(sizeof($array)>1){
  32.             $arrayReturn = $array;
  33.  
  34.         };
  35.  
  36.         return $arrayReturn;       
  37.     }
  38.  
  39.  
Jul 15 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: badz | last post by:
Hi frenz Lately I try to use MSSQL and PHP , the problem arise when PHP try to read MSSQL field with 'image' data type, header("Content-type: image/jpeg"); // act as a jpg file to browser I...
7
by: mj | last post by:
Hello, thanks for the help. I am running a WinXP Pro w/ SP2 (my home computer, with ZoneAlarm firewall) Apache 2.0.52 MySQL 4.1.7 PHP 5.1.0-dev I have developed a PHP/MySQL web app that...
3
by: tdmailbox | last post by:
I need to migrate data from one sql database to another. The second DB is a newer version of the "old" database with mostly the same tables and fieldnames. In order support some reporting queries...
8
by: Yusuf INCEKARA | last post by:
I have a stored procedure : CREATE PROCEDURE STP_GETSTORELIST @RETCUR CURSOR VARYING OUTPUT AS set @RETCUR = CURSOR FORWARD_ONLY STATIC FOR SELECT ID,STORE_NAME FROM T_INF_STORE ORDER BY...
1
by: wallacee | last post by:
Five year PL/SQL programmer with a MSSQL question. I need to spool (the PL/SQL verb) output to a file from an MSSQL statement. In PL/SQL it would look like: spool myoutput.txt select...
0
by: Metalzed | last post by:
Hi I have a little problem If I use the this C# code DateTime.Now.ToString() output = 2006-11-03 06:15:17 But if i use this code in MSSQL (CONVERT(VARCHAR(35), { fn NOW() })) output= Nov 3...
1
by: srinivd1 | last post by:
Hi, I have a tabbed pane with 3 tabs.The content of each pane is going to be a different html based on from where the page is called. Now, i have defined the div tag for each of the panes as...
2
by: pks83 | last post by:
In MSSQL I am using datetime as the column type and trying to execute the below mentioned query select time from tickets where ticket_id = '1'; when i execute the query on sql manager window it...
1
by: David Gillen | last post by:
Hello. I'm having difficulty getting the value of output parameters from stored procedures on a SQL server. I understand that this just doesn't work with odbc so I've tried both the mssql...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.