To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here

HOME News MS SQL Oracle DB2 Access MySQL PHP Scripts Books Links DBA Talk


Go Back   Database Journal Forums > Miscellaneous > Database Programming

Database Programming Discussion on all database programming topics, including ASP-db, ASP.NET, ASP and PHP.

Reply Post New Thread
 
Thread Tools Rate Thread Display Modes
  #1  
Old 01-25-2010, 12:09 PM
jhannley jhannley is offline
Registered User
 
Join Date: Jan 2010
Posts: 1
PHP ODBC Connection to Paradox DB

Hi,

I have a paradox DB that I created a DSN ODBC connection with in Windows 2008. I also have apache running on the same box.

I am trying to connect to the db via ODBC and PHP but I have hit some serious road blocks.

My PHP script, parses the DB and extracts the information to a MYSQL database every 10 seconds. The issue is that it dies, not when I connect to the ODBC datasource but when I query against it! But it's not consistent.... for example:

There are times when my script runs without any issues!
There are times when it dies completely barfing error code: S0002 - essentially telling me it can't find the table.
There are times when it consistently works one iteration and then dies every second iteration...

I can view this database in EXCEL, 100% at all times via ODBC!

Does anyone have any suggestions or thoughts onto what's happening here?

Thanks,
Jeremiah

Code:
  include "DatabaseHandler.php";
  
  //for each file in folder that has an extension .db
  //parse and upload to database
  //remove/delete file when finished

  ini_set('memory_limit', '64M');
  //set_time_limit(300);           
  
  echo "Start@(".date('h:i:s').")</br>";
  ExtractFromParadoxInsertIntoSQL($ParadoxDatabase);
  
  /*
  * @desc Grabs events from paradox db and dumps them into a SQL file
  */
  function ExtractFromParadoxInsertIntoSQL($db){

   // include_once "DatabaseHandler.php";   
    define ('PkMessageInfo', 1);
    define ('DateTime', 6);
    define ('MessageType', 7);
    define ('Message', 8);
    define ('Message1', 9);
    define ('Message2', 10);
    define ('ObjectDescription1', 24);
    define ('Description11', 25);
    define ('Description12', 26);
    define ('ObjectDescription2', 28);
    define ('Description21', 29);
    define ('Description22', 30);
    define ('ObjectDescription3', 32);
    define ('Description31', 33);
    define ('Description32', 34);

    try{
                                      
      //copy file
      copy("C:/Program Files/KT/Data/messageinfo.db","c:/xampp/htdocs/myprogram/paradox.db");
      $connection = odbc_connect("paradox.DB","",""); 
      
     $from = Date('Y-m-d H:i:s', strtotime('-5 hours')); //today minus 5 hours 
      
      $strQuerySQL = "SELECT * FROM messageinfo
                      WHERE datetime >{ts '$from'}
                      AND (messagetype=65 or messagetype=72)
                      ";


/*
*  THE FOLLOWING LINE OF CODE SEEMS TO NOT WORK ALL THE TIME :mad::mad::mad:
*/
      $result = odbc_exec($connection, $strQuerySQL) or die(odbc_errormsg($connection));


      
 
     $iCount = 0;  
      while( odbc_fetch_row( $result ) ) {
        $intPKMessageInfo = odbc_result($result, PkMessageInfo);
        $dateDateTime = odbc_result($result, DateTime);
        $intMessageType = odbc_result($result, MessageType);
        $intMessage = odbc_result($result, Message);
        $strMessage1 = odbc_result($result, Message1);
        $strMessage2 = odbc_result($result, Message2);
        $intObjectDescription1 = odbc_result($result, ObjectDescription1);
        $strDescription11 = odbc_result($result, Description11);
        $strDescription12 = odbc_result($result, Description12);
        $intObjectDescription2 = odbc_result($result, ObjectDescription2);
        $strDescription21 = odbc_result($result, Description21);
        $strDescription22 = odbc_result($result, Description22);
        $intObjectDescription3 = odbc_result($result, ObjectDescription3);
        $strDescription31 = odbc_result($result, Description31);
        $strDescription32 = odbc_result($result, Description32);
        
        
         echo "<tr>";
         echo "<td>$intPKMessageInfo</td>";
         echo "<td>$dateDateTime</td>";
         echo "<td>$intMessageType</td>";
         echo "<td>$intMessage</td>";
         echo "<td>$strMessage1</td>";
         echo "<td>$strMessage2</td>";
         echo "<td>$intObjectDescription1</td>";
         echo "<td>$strDescription11</td>";
         echo "<td>$strDescription12</td>";
         echo "<td>$intObjectDescription2</td>";
         echo "<td>$strDescription21</td>";
         echo "<td>$strDescription22</td>";
         echo "<td>$intObjectDescription3</td>";
         echo "<td>$strDescription31</td>";
         echo "<td>$strDescription32</td>";
         echo "</tr>";
        
       
        $iCount++;
                            
      }
      echo "</table>";
     
     echo "Number of events crunched:$iCount</br>";
     echo "Done@(" . date('h:i:s').")";
     odbc_close($connection);
    } catch (Exception $e) {
        print("ExtractFromParadoxInsertIntoSQL: ");
        var_dump($e->getMessage());
        $lf = new logfile();
        $lf->write(var_dump($e->getMessage()) . "\r\n");
    }
  }
      
  }
Reply With Quote
  #2  
Old 01-27-2010, 08:45 PM
Frank Frank is offline
Super Moderator
 
Join Date: Oct 2002
Posts: 929
Wrong forum

This is an ASP forum. You ned to go to the PhP forum. If you are still using ODBC, you are several generation behind. Check out www.aspdb.com to see how wasy it is to generate a Web DB application.

Frank
Reply With Quote
Reply Post New Thread

Bookmarks

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 02:05 PM.


DatabaseJournal Recent Articles


 » Top 10 SQL Server 2008 Database Administra...

 » A First Look at SQL Server 2008 R2 Master ...

 » Redmond exploits MySQL uncertainty

 » Oracle Launches Oracle Global Trade Manage...

 » SQL Server 2008 RTM Support Ends April 13,...

Search Database Journal:
 







Acceptable Use Policy

Internet.com
The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers

Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.