Duckington's Profile User Rating: -----

Reputation: 164 Stalwart
Group:
Active Members
Active Posts:
596 (0.36 per day)
Joined:
12-October 09
Profile Views:
9,126
Last Active:
User is offline Apr 17 2014 08:53 AM
Currently:
Offline

Previous Fields

Country:
GB
OS Preference:
Windows
Favorite Browser:
Opera
Favorite Processor:
Who Cares
Favorite Gaming Platform:
PC
Your Car:
Ford
Dream Kudos:
0

Latest Visitors

Icon   Duckington has not set their status

Posts I've Made

  1. In Topic: Connecting PHP from Linux to SQL Server

    Posted 3 Oct 2013

    Even converting & casting everything doesn't work :-(

    SELECT EVENT_DESC, DAY_OF_WEEK, DAY_NUMBER, END_DATE, 
    END_TIME, TID, DESCRIPTION, ROOM, STAFF, START_DATE, 
    START_TIME, PCODE, CONVERT(char(10), END_DATE, 112) as enddate, 
    CONVERT(char(10), START_DATE, 112) as startdate 
    
    FROM [MIS_MOODLE_TT] 
    
    WHERE [PCODE] LIKE :PCODE 
    AND [DAY_NUMBER] LIKE :DAY_NUMBER 
    AND CONVERT(integer, CONVERT(char(10), [START_DATE], 112)) <= CAST(:START_DATE as integer) 
    AND CONVERT(integer, CONVERT(char(10), [END_DATE], 112)) >= CAST(:END_DATE as integer)
    
    ORDER BY [START_TIME]
    
    
  2. In Topic: Connecting PHP from Linux to SQL Server

    Posted 3 Oct 2013

    Nope, still doesn't like it.

    SELECT EVENT_DESC, DAY_OF_WEEK, DAY_NUMBER, END_DATE, 
    END_TIME, TID, DESCRIPTION, ROOM, STAFF, START_DATE, 
    START_TIME, PCODE, CONVERT(char(10), END_DATE, 112) as enddate, 
    CONVERT(char(10), START_DATE, 112) as startdate 
    
    FROM [MIS_MOODLE_TT] 
    
    WHERE [PCODE] LIKE :PCODE 
    AND [DAY_NUMBER] LIKE :DAY_NUMBER 
    AND DATEDIFF(SECOND, '1970-01-01 00:00:00', [START_DATE]) <= :START_DATE 
    AND DATEDIFF(SECOND, '1970-01-01 00:00:00', [END_DATE]) >= :END_DATE 
    
    ORDER BY [START_TIME]
    
    


    array(4) { 
    ["PCODE"]=> string(5) "71720" 
    ["DAY_NUMBER"]=> string(1) "4" 
    ["START_DATE"]=> int(1380758400) 
    ["END_DATE"]=> int(1380758400) 
    } 
    
    



    Invalid character value for cast specification: 206 [FreeTDS][SQL Server]Operand type clash: text is incompatible with int (SQLExecute[206] at /builddir/build/BUILD/php-5.3.3/ext/pdo_odbc/odbc_stmt.c:254) 
    
    
  3. In Topic: Connecting PHP from Linux to SQL Server

    Posted 3 Oct 2013

    [Deleted]
  4. In Topic: Connecting PHP from Linux to SQL Server

    Posted 2 Oct 2013

    View PostAtli, on 02 October 2013 - 05:44 PM, said:

    Hey.

    Have you considered casting both values to actual numbers? The problem there seems to be that the driver you are using on Linux doesn't allow this type of comparison between char and text types. That shouldn't be a problem if you just cast things to integers.

    You could either use the same date format you are using now, just in integer for, or even convert both to Unix timestamps.
    -- Here :END_DATE would be an integer from PHP. Simpler. Otherwise
    -- it would have to be cast as well here, which would be less ideal.
    CONVERT(integer, CONVERT(char(10), [END_DATE], 112)) >= :END_DATE
    
    -- And here :END_DATE would be an Unix timestamp from PHP.
    DATEDIFF(SECOND, '1970-01-01 00:00:00', [END_DATE]) >= :END_DATE
    
    


    Hi,

    Thanks for the response.

    I've just tried that, but it still doesn't like it.

    Here is the SQL and the params being passed into the statement:

    SELECT EVENT_DESC, DAY_OF_WEEK, DAY_NUMBER, END_DATE, END_TIME, TID, 
    DESCRIPTION, ROOM, STAFF, START_DATE, START_TIME, PCODE, 
    CONVERT(char(10), END_DATE, 112) as enddate, CONVERT(char(10), START_DATE, 112) as startdate 
    
    FROM [MIS_MOODLE_TT] 
    
    WHERE [PCODE] LIKE :PCODE 
    AND [DAY_NUMBER] LIKE :DAY_NUMBER 
    AND CONVERT(integer, CONVERT(char(10), [START_DATE], 112)) <= :START_DATE 
    AND CONVERT(integer, CONVERT(char(10), [END_DATE], 112)) >= :END_DATE 
    
    ORDER BY [START_TIME]
    
    


    array(4) { 
    ["PCODE"]=> string(5) "71720" 
    ["DAY_NUMBER"]=> string(1) "3" 
    ["START_DATE"]=> int(20131002) 
    ["END_DATE"]=> int(20131002) 
    }
    
    


    So I'm converting it to an integer in the query and the variable being passed in is an int, but now I get:

    SQLSTATE[22018]: Invalid character value for cast specification: 206 [FreeTDS][SQL Server]Operand type clash: text is incompatible with int (SQLExecute[206] at /builddir/build/BUILD/php-5.3.3/ext/pdo_odbc/odbc_stmt.c:254)
    
    


    I've done a bit more googling and according to this link:

    http://stackoverflow...ompatible-in-th

    It seems that there might be a bug in the 64 bit odbc driver, which could explain why this worked fine last year as we were on 32 bit..

    I suppose I could try recompiling php with the 32 bit version, though that would be a major pain. :(

    [EDIT] I tell a lie, the development linux server is 32 bit.
  5. In Topic: What are you working on today?

    Posted 21 Jun 2013

    Had to demo a system I've been working on this morning, went alright, but I hate presenting things, I always get my words muddled up.

My Information

Member Title:
D.I.C Addict
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:
Years Programming:
3
Programming Languages:
PHP

Contact Information

E-mail:
Private

Friends

Comments

Page 1 of 1
  1. Photo

    Tom_Leonardsson Icon

    25 Apr 2012 - 07:17
    Die.
  2. Photo

    e_i_pi Icon

    03 Apr 2012 - 15:20
    Hey, what's the URL of the game you're making? I wouldn't mind checking it out
  3. Photo

    hiddenghost Icon

    03 Mar 2012 - 06:01
    I never check the comments on my profile. What thread of mine broke the forum? :)
  4. Photo

    cbz_extreme Icon

    25 Dec 2011 - 03:49
    Hello!!!
Page 1 of 1