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 -
SELECT DISTINCT
-
dbo.events.showPrice, dbo.events.eventID, dbo.events.categoryID, dbo.events.eventName, dbo.events.eventDetails, dbo.events.eventLive,
-
dbo.eventCategories.categoryName, eventCategories_1.categoryName AS categoryParent, dbo.events.enabled, tickets_1.ticketStartDate,
-
MIN(tickets_1.ticketPrice) AS priceFrom, dbo.venues.venueID, dbo.venues.venueName, dbo.venues.venueAddress1, dbo.venues.venueCity,
-
dbo.venues.venueCounty, dbo.texts.text, '1' AS test,
-
(SELECT MIN(ticketStartDate) AS minStart
-
FROM dbo.tickets
-
WHERE (eventID = 184) AND (ticketStartDate > CASE WHEN Datepart(dw, getdate()) <= 6 AND ticketEndDate > getdate() AND
-
ticketEndDate < DATEADD(DAY, 2, GETDATE()) THEN getDate() ELSE DATEADD(DAY, 2, GETDATE()) END)) AS minStart,
-
(SELECT MAX(ticketStartDate) AS maxEnd
-
FROM dbo.tickets AS tickets_2
-
WHERE (eventID = 184) AND (ticketStartDate > GETDATE())) AS maxEnd
-
FROM dbo.events INNER JOIN
-
dbo.eventCategories ON dbo.events.categoryID = dbo.eventCategories.categoryID LEFT OUTER JOIN
-
dbo.eventCategories AS eventCategories_1 ON dbo.eventCategories.categoryParent = eventCategories_1.categoryID INNER JOIN
-
dbo.tickets AS tickets_1 ON dbo.events.eventID = tickets_1.eventID LEFT OUTER JOIN
-
dbo.venues ON tickets_1.venueID = dbo.venues.venueID LEFT OUTER JOIN
-
dbo.texts ON tickets_1.textsID = dbo.texts.textsID
-
WHERE (tickets_1.ticketEndDate > CASE WHEN Datepart(dw, getdate()) <= 6 AND tickets_1.ticketEndDate > getdate() AND
-
tickets_1.ticketEndDate < DATEADD(DAY, 2, GETDATE()) THEN getDate() ELSE DATEADD(DAY, 2, GETDATE()) END)
-
GROUP BY dbo.events.eventID, dbo.events.categoryID, dbo.events.eventName, dbo.events.eventDetails, dbo.events.eventLive, dbo.events.showPrice,
-
dbo.eventCategories.categoryName, eventCategories_1.categoryName, tickets_1.ticketEndDate, dbo.events.enabled, tickets_1.ticketStartDate,
-
dbo.venues.venueName, dbo.venues.venueID, dbo.venues.venueAddress1, dbo.venues.venueCity, dbo.venues.venueCounty, dbo.texts.text
-
HAVING (dbo.events.eventID = 184) AND (dbo.events.enabled = 1) AND (MONTH(tickets_1.ticketStartDate) = MONTH(GETDATE())) AND
-
(YEAR(tickets_1.ticketStartDate) = YEAR(GETDATE()))
-
My initial thinking is maybe the date is wrong in php? iis? or mssql?
What do you think?
Thanks so much in advance
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.
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
Thanks for the help so far.
Below is the code i run; -
$eventsDetail = $detail->eventsGetTheatreDates($itemID,0,0);
-
-
print_r($eventsDetail);
-
-
which calls -
public function eventsGetTheatreDates($itemID,$month,$year){
-
-
global $db;
-
-
$rs = $db->databaseQuery('exec eventsGetTheatreDates '.$itemID.','.$month.','.$year);
-
$row = $db->databaseResult($rs);
-
-
$db->databaseDisconnect();
-
-
return $row;
-
}
-
Which calls -
public function databaseQuery($query)
-
{
-
$results = odbc_exec($this->conn,$query);
-
}
-
-
public function databaseResult($rs)
-
{
-
$i = 0;
-
$j = 0;
-
$arrayTemp = "";
-
$arrayItem = "";
-
$arrayReturn = "";
-
$array = "";
-
$arrayReturn["oneRow"] = TRUE;
-
-
while(odbc_fetch_row($rs))
-
{
-
-
for ($j = 1; $j <= odbc_num_fields($rs); $j++)
-
{
-
$field_name = odbc_field_name($rs, $j);
-
$arrayItem[$field_name] = odbc_result($rs, $field_name);
-
$arrayReturn[$field_name] = odbc_result($rs, $field_name);
-
-
}
-
-
$array[$i] = $arrayItem;
-
$i++;
-
}
-
-
if(sizeof($array)>1){
-
$arrayReturn = $array;
-
-
};
-
-
return $arrayReturn;
-
}
-
-
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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...
|
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...
|
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...
|
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...
| |