criostage Posted November 20, 2013 Share Posted November 20, 2013 Hello all, i m doing this small piece of code to test out how can i get some data out of an mdb file, so i can peridicly check it and import new data into something easier to work with ... example MySQL. This script is to runned as a cron job, so i m running it using the php cli, this is the code i have so far: <?php error_reporting(E_ALL); ini_set( 'display_errors', 1 ); $mdbfile = "/var/www/html/db.mdb"; if( file_exists( $mdbfile ) ){ try { $dbh = new PDO("odbc:DRIVER={MsAccess};DSN=mdbtest;"); $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); }catch (PDOException $e) { echo $e->getMessage(); } }else{ die('File does not exist!'); } foreach ( $dbh->query("SELECT * FROM MY_TABLE") as $row ){ echo $row['Row1']; } if(isset($dbh)){ $dbh = null; } ?> when i run "php -f /var/www/html/php-pdo-odbc.php", i get the error "Segmentation fault", if i try to open the file from the web browser i get an error "The connection was reset". Commenting out some code i figured out that the error is in the foreach, but i dont see any issue with it .. could anyone give me an though why is this happening? I m using CentOS 6.4 with Apache 2 and PHP5.5.6. Thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/284097-segmentation-fault-issue/ Share on other sites More sharing options...
QuickOldCar Posted November 20, 2013 Share Posted November 20, 2013 (edited) nvm, read the code wrong in my response Edited November 20, 2013 by QuickOldCar Quote Link to comment https://forums.phpfreaks.com/topic/284097-segmentation-fault-issue/#findComment-1459175 Share on other sites More sharing options...
mac_gyver Posted November 20, 2013 Share Posted November 20, 2013 Segmentation faults are usually due to actual bugs in the underlying code or having a mix of different versions of php core files and extensions (i.e. not all built with the same c header files.) is there any additional information in the web server's error log file? you can check the php bug reports to see if anyone else is having the same problem and/or make a bug report if you feel this is something due to the underlying php code. (php 5.5.6 just fixed a segfault if the PDO constructor throws an exception, perhaps this is related to that.) the only thing i can suggest you can try in the code would be to put a try/catch block around the foreach(){} block in case the query statement is failing and throwing an uncaught exception. temporarily turning off the PDO::ERRMODE_EXCEPTION may help pin point the issue (if its an actual bug in php.) Quote Link to comment https://forums.phpfreaks.com/topic/284097-segmentation-fault-issue/#findComment-1459182 Share on other sites More sharing options...
criostage Posted November 20, 2013 Author Share Posted November 20, 2013 Hi thank you for your response, i did a couple of tests (including installing php 5.3.3) i get the same result as i described. I further found that mdbtools (the driver that was installed in the unixODBC) last version is from the year 2004, at this point i have no idea what to do ... thank you very much for your reply tho. Quote Link to comment https://forums.phpfreaks.com/topic/284097-segmentation-fault-issue/#findComment-1459199 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.