SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Mar 2004
    Location
    South Africa
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question PHP UNIXODBC help, I'm stumped and confused

    Hi guys, I'm using UNIXODBC to communicate with a MSSQL Server. I've got this crazy query that works in a direct SQL connection tool but in the PHP webpage it doesnt work. Could somebody help me out, I'll paste the code below.

    THE STRAIGHT SQL version vuia connection tool
    =============================================

    select DISTINCT

    Itm_Itemnr,Itm_ISBNNr,Itm_Outeur,Itm_AfrikaPrys,
    Itm_DollarPrys,Itm_PondPrys,Itm_EuroPrys,
    Itm_WebStatus,Itm_SellOnWeb ,
    Bb_Itemnr,Bb_Translated,Bb_Language,Bb_Title,Bb_SubTitle,

    CONVERT (VARCHAR(1500),Bb_KortBeskrywing) AS Short,
    Img_Itemnr,Img_Image,
    IKat_Itemnr, IKat_Kategorie,Itm_Prys

    from Items

    INNER JOIN BoekBeskrywing ON Itm_Itemnr = Bb_Itemnr
    INNER JOIN Image ON Itm_Itemnr = Img_Itemnr
    INNER JOIN ItemKategorie ON Itm_Itemnr = Kat_Itemnr

    WHERE Itm_SellOnWeb =1 AND IKat_Kategorie ='Art';


    =============================================

    here's ther web version

    $sqlconnect=odbc_connect($dsn, $SQLUser,$SQLPass);
    $odbcsql="select DISTINCT Itm_Itemnr,Itm_ISBNNr,Itm_Outeur,Itm_AfrikaPrys,
    Itm_DollarPrys,Itm_PondPrys,Itm_EuroPrys,
    Itm_WebStatus,Itm_SellOnWeb ,
    Bb_Itemnr,Bb_Translated,Bb_Language,Bb_Title,Bb_SubTitle,
    CONVERT (VARCHAR(1500),Bb_KortBeskrywing) AS Short,
    Img_Itemnr,Img_Image,
    IKat_Itemnr, IKat_Kategorie,Itm_Prys
    from Items
    INNER JOIN BoekBeskrywing ON Itm_Itemnr = Bb_Itemnr
    INNER JOIN Image ON Itm_Itemnr = Img_Itemnr
    INNER JOIN ItemKategorie ON Itm_Itemnr = IKat_Itemnr
    WHERE Itm_SellOnWeb =1 AND IKat_Kategorie ='Art';";

    $process=odbc_exec($sqlconnect,$odbcsql);

  2. #2
    SitePoint Author silver trophybronze trophy
    wwb_99's Avatar
    Join Date
    May 2003
    Location
    Washington, DC
    Posts
    10,633
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    What error are you getting?

    Did you install the libraries it says it requires for the SQL server functions to work? Might also be needed for SQL server over odbc.

    In addition, have you setup an ODBC DSN? Does it point to a specific database?

    WWB

  3. #3
    SitePoint Member
    Join Date
    Mar 2004
    Location
    South Africa
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by wwb_99
    What error are you getting?

    Did you install the libraries it says it requires for the SQL server functions to work? Might also be needed for SQL server over odbc.

    In addition, have you setup an ODBC DSN? Does it point to a specific database?

    WWB
    Thats the funny thing. just no rows returned. In fact I just tried to run with just

    IKat_Kategorie LIKE 'Music' or IKat_Kategorie = 'Music' and still no rows

    I've setup the right drivers and DSN, it will return rows as long as I dont try and match against any text.

    For example I could go where webitem =1 AND price >$40 and that works fine

  4. #4
    SitePoint Author silver trophybronze trophy
    wwb_99's Avatar
    Join Date
    May 2003
    Location
    Washington, DC
    Posts
    10,633
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Hmm. I think I saw something about this when looking at the PHP/ODBC bugs. You might want to post something there.

    Another thing to try would be to create a stored proc, rather than passing raw SQL.

    WWB

  5. #5
    SitePoint Member
    Join Date
    Mar 2004
    Location
    South Africa
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    which forum is that specifically

    Quote Originally Posted by wwb_99
    Hmm. I think I saw something about this when looking at the PHP/ODBC bugs. You might want to post something there.

    Another thing to try would be to create a stored proc, rather than passing raw SQL.

    WWB

    The one with PHP/ODBC bugs?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •