moisesbr Posted August 22, 2013 Share Posted August 22, 2013 Hi I am getting error: Fatal error: Call to undefined function dbase_open() in C:\wamp\www\test\import.php on line 20Then I downloade and saved php_dbase. dll And line in php ini: extension=php_dbase.dll, but still getting error. All in folder: C:\wamp\bin\php\php5.4.12 Is it enough ? Quote Link to comment https://forums.phpfreaks.com/topic/281470-undefined-function-dbase_open/ Share on other sites More sharing options...
moisesbr Posted August 22, 2013 Author Share Posted August 22, 2013 saved it aso to /ext, reloaded php, but I have message: Unable to load dinamic library ... ext/php_dabase.dll %1 It is not a valid win 32 Quote Link to comment https://forums.phpfreaks.com/topic/281470-undefined-function-dbase_open/#findComment-1446293 Share on other sites More sharing options...
mac_gyver Posted August 22, 2013 Share Posted August 22, 2013 what database server type are you trying to use? Quote Link to comment https://forums.phpfreaks.com/topic/281470-undefined-function-dbase_open/#findComment-1446294 Share on other sites More sharing options...
moisesbr Posted August 22, 2013 Author Share Posted August 22, 2013 Hi I want to import .dbf files (Visual Foxpro) to mysql database.I am running tests in windows 7 , 64bit. Moises Quote Link to comment https://forums.phpfreaks.com/topic/281470-undefined-function-dbase_open/#findComment-1446296 Share on other sites More sharing options...
mac_gyver Posted August 22, 2013 Share Posted August 22, 2013 the php_dbase.dll file must be compiled for the same version and thread-safe or non-thread-safe flavor of php that you are using. where did you get this php_dbase.dll file at? Quote Link to comment https://forums.phpfreaks.com/topic/281470-undefined-function-dbase_open/#findComment-1446301 Share on other sites More sharing options...
mac_gyver Posted August 22, 2013 Share Posted August 22, 2013 (edited) here is an alternative (untested) method - http://www.phpclasses.org/package/2673-PHP-Access-dbf-foxpro-files-without-PHP-ext-.html and another one - http://www.phpclasses.org/package/1302-PHP-Extract-information-from-a-DBF-database-file.html Edited August 22, 2013 by mac_gyver Quote Link to comment https://forums.phpfreaks.com/topic/281470-undefined-function-dbase_open/#findComment-1446303 Share on other sites More sharing options...
moisesbr Posted August 22, 2013 Author Share Posted August 22, 2013 (edited) the php_dbase.dll file must be compiled for the same version and thread-safe or non-thread-safe flavor of php that you are using. where did you get this php_dbase.dll file at? I got it somewhere over the net, and maybe this is the problem. Don't you know if there are a full package to install support for dbase_open() function, rather than pure dll copy ? Edited August 22, 2013 by moisesbr Quote Link to comment https://forums.phpfreaks.com/topic/281470-undefined-function-dbase_open/#findComment-1446324 Share on other sites More sharing options...
moisesbr Posted August 22, 2013 Author Share Posted August 22, 2013 Below is the code is the code I am trying. It calls dbase_open() function, but problem is enabling this function. /* * Part 2 code modified by Clint Christopher Canada from different public domain sources * Part 1 code created by Clint Christopher Canada. BSD licensed. */ // This is Part I of the code $tbl = "table to create"; $db_uname = 'mysql username'; $db_passwd = 'mysql password'; $db = 'database'; $conn = mysql_pconnect('localhost',$db_uname, $db_passwd); // Path to dbase file $db_path = ".DBF"; // Open dbase file $dbh = dbase_open($db_path, 0) or die("Error! Could not open dbase database file '$db_path'."); // Get column information $column_info = dbase_get_header_info($dbh); // Display information //print_r($column_info); $line = array(); foreach($column_info as $col) { switch($col['type']) { case 'character': $line[]= "`$col[name]` VARCHAR( $col[length] )"; break; case 'number': $line[]= "`$col[name]` FLOAT"; break; case 'boolean': $line[]= "`$col[name]` BOOL"; break; case 'date': $line[]= "`$col[name]` DATE"; break; case 'memo': $line[]= "`$col[name]` TEXT"; break; } } $str = implode(",",$line); $sql = "CREATE TABLE `$tbl` ( $str );"; mysql_select_db($db,$conn); mysql_query($sql,$conn); set_time_limit(0); // I added unlimited time limit here, because the records I imported were in the hundreds of thousands. // This is part 2 of the code import_dbf($db, $tbl, $db_path); function import_dbf($db, $table, $dbf_file) { global $conn; if (!$dbf = dbase_open ($dbf_file, 0)){ die("Could not open $dbf_file for import."); } $num_rec = dbase_numrecords($dbf); $num_fields = dbase_numfields($dbf); $fields = array(); for ($i=1; $i<=$num_rec; $i++){ $row = @dbase_get_record_with_names($dbf,$i); $q = "insert into $db.$table values ("; foreach ($row as $key => $val){ if ($key == 'deleted'){ continue; } $q .= "'" . addslashes(trim($val)) . "',"; // Code modified to trim out whitespaces } if (isset($extra_col_val)){ $q .= "'$extra_col_val',"; } $q = substr($q, 0, -1); $q .= ')'; //if the query failed - go ahead and print a bunch of debug info if (!$result = mysql_query($q, $conn)){ print (mysql_error() . " SQL: $q \n"); print (substr_count($q, ',') + 1) . " Fields total. "; $problem_q = explode(',', $q); $q1 = "desc $db.$table"; $result1 = mysql_query($q1, $conn); $columns = array(); $i = 1; while ($row1 = mysql_fetch_assoc($result1)){ $columns[$i] = $row1['Field']; $i++; } $i = 1; foreach ($problem_q as $pq){ print "$i column: {$columns[$i]} data: $pq \n"; $i++; } die(); } } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/281470-undefined-function-dbase_open/#findComment-1446325 Share on other sites More sharing options...
mac_gyver Posted August 22, 2013 Share Posted August 22, 2013 of the two links i posted above, the first one is more through and includes an api that emulates the dbase functions. it looks like you can just change the function names from dbase to xbase Quote Link to comment https://forums.phpfreaks.com/topic/281470-undefined-function-dbase_open/#findComment-1446335 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.