Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2007
    Posts
    2

    Unanswered: Problem with a PHP/SQL script connecting to a ODBC datasource

    I'm using php to run a very simple select query from a sql server. The problem is the script no longer works. I recently did an upgrade to the software that the script reports from and since then it doesn't work. The software company says maybe I should try using OLE DB instead of ODBC... Although I've never worked with it.

    Here is the connection string and query. Any help will be greatly appreciated.
    <?php
    if(isset($Submit))
    {
    //connect to the database
    $connectionstring = odbc_connect("datasource","sa", "password");

    //SQL query
    if($mlist == "all") {
    $Query = "SELECT Bin.MyNo, Bin.Item, Bin.Burnqty, Bin.Type, item.description1, item.description2, item.mfg, bin.station
    FROM autocrib5.dbo.Bin
    INNER JOIN autocrib5.dbo.item ON bin.item=item.code
    WHERE autocrib5.dbo.item.description1 like '%$des%'

    and autocrib5.dbo.bin.item <> '000-000'
    order by autocrib5.dbo.bin.item";

    } else {

    $Query = "SELECT Bin.MyNo, Bin.Item, Bin.Burnqty, Bin.Type, item.description1, item.description2, item.mfg, bin.station
    FROM autocrib5.dbo.Bin
    INNER JOIN autocrib5.dbo.item ON bin.item=item.code
    WHERE autocrib5.dbo.item.description1 like '%$des%'
    and autocrib5.dbo.item.mfg = '$mlist'

    and autocrib5.dbo.bin.item <> '000-000'
    order by autocrib5.dbo.bin.item";
    }
    $queryexe = odbc_do($connectionstring, $Query);

    //query database
    while(odbc_fetch_row($queryexe))
    {
    $itemnum = odbc_result($queryexe, 2);
    $onhand = odbc_result($queryexe, 3);
    $descript = odbc_result($queryexe, 5);
    $descript2 = odbc_result($queryexe, 6);
    $manuf = odbc_result($queryexe, 7);

  2. #2
    Join Date
    Jan 2007
    Posts
    2
    Problem fixed, the sql server wasn't started correctly and I just had to restart the service.

Posting Permissions

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