If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Pervasive.SQL > Problems with odbc connection

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-06-07, 11:45
johnnytang24 johnnytang24 is offline
Registered User
 
Join Date: Jun 2007
Posts: 6
Problems with odbc connection

Hi all,

Does anyone know why I would be unable to connect via php / odbc to a Pervasive database? I can use isql to connect to pervasive and run queries, and I can use the php odbc functions with mysql, but I cannot use PHP / odbc with Pervasive. The result is a core dump.

I am using Pervasive 9.10-020.000. I have tried both the rpm and tgz.
Suse 10.1
PHP 5.1.2
unixODBC 2.2.11
Linux 2.6.16.13

Thanks
Reply With Quote
  #2 (permalink)  
Old 07-06-07, 21:12
mirtheil mirtheil is offline
Registered User
 
Join Date: Dec 2001
Posts: 1,026
So if I understand correctly, your PSQL database is on the Linux server where PHP is running.
Have you tried running PHP from the command line to execute the page that accesses the PSQL ODBC?
What kind of PHP page have you tried? Is it simply an ODBC Connect or does it do more than that?
Here's a page I've tried in the past that has worked:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>PHP Sample</TITLE>
</HEAD>
<BODY>
<?php
$conn=odbc_connect("Demodata","","",""); 
$sql="select * from class";
$rs=odbc_exec($conn,$sql);  
echo "<table border=1>\n";
$numfields = odbc_num_fields($rs);
for($i=1;$i<=$numfields;$i++){
	$fn=odbc_field_name($rs,$i);
	echo "<th>$fn</th>";
}
echo "\n";
while(odbc_fetch_row($rs)){ 
	echo "<tr>\n";
	for($i=1;$i<=$numfields;$i++){
	   $fv=odbc_result($rs,$i);
	   echo "<td>$fv</td>";
	}   
	echo "</tr>\n";
} 
echo "</table>\n";
echo "<p>Number of Fields: $numfields</p>\n";
?>
</BODY>
</HTML>
Does that work for you? It uses the PSQL DEMODATA database.
Also, have you tried PSQL v9.5? It's the current version of PSQL and is a service pack for PSQL 9.10.
__________________
Mirtheil Software
Certified Pervasive Developer
Certified Pervasive Technician
Custom Btrieve/VB development
http://www.mirtheil.com
I do not answer questions by email. Please post on the forum.
Reply With Quote
  #3 (permalink)  
Old 07-06-07, 21:56
johnnytang24 johnnytang24 is offline
Registered User
 
Join Date: Jun 2007
Posts: 6
My apologies. PSQL is running on a Win2K3 server. I can use isql from the Linux command line to connect to the remote PSQL server, but cannot use PHP to connect.

# cat test.php
<?
$conn = odbc_connect("Demodata", "", "");
?>

# php5 test.php
Segmentation fault (core dumped)

# gdb php5 core
> bt
#0 0xb7c4bf6f in free () from /lib/libc.so.6
#1 0xb6bf45d8 in MemFree () from /usr/lib/libtidy-0.99.so.0
#2 0xb4abe7c1 in fStrGetPathName () from /usr/local/psql/lib/odbcci.so
#3 0xb4abd5b0 in lenStrGetProfileString_priv () from /usr/local/psql/lib/odbcci.so
#4 0xb4abe821 in lenStrGetProfileString () from /usr/local/psql/lib/odbcci.so
#5 0xb4abeea9 in hTrcInit () from /usr/local/psql/lib/odbcci.so
#6 0xb4a8f176 in hDrvTrcInit () from /usr/local/psql/lib/odbcci.so
#7 0xb4a6f097 in _SimSQLConnect () from /usr/local/psql/lib/odbcci.so
#8 0xb4a70106 in SQLConnect () from /usr/local/psql/lib/odbcci.so
#9 0xb7032267 in SQLConnect () from /usr/local/psql/lib/libodbc.so.1
#10 0xb70d3c9d in odbc_sqlconnect () from /usr/lib/php5/extensions/odbc.so
#11 0xb70db4d4 in odbc_do_connect () from /usr/lib/php5/extensions/odbc.so
#12 0xb70db6e5 in zif_odbc_connect () from /usr/lib/php5/extensions/odbc.so
#13 0x081a743b in zend_get_user_opcode_handler ()
#14 0x081a8839 in execute ()
#15 0x0818bb49 in zend_execute_scripts ()
#16 0x081516c2 in php_execute_script ()
#17 0x0820309e in main ()

Thanks
Reply With Quote
  #4 (permalink)  
Old 07-06-07, 22:03
johnnytang24 johnnytang24 is offline
Registered User
 
Join Date: Jun 2007
Posts: 6
Also, I have not upgraded to PSQL 9.50 because I am not unsure about maintaining data integrity. There is some accounting software using the DB, and I cannot upgrade and test.

Thanks.
Reply With Quote
  #5 (permalink)  
Old 07-06-07, 22:40
mirtheil mirtheil is offline
Registered User
 
Join Date: Dec 2001
Posts: 1,026
Dumb question, is Linux a requirement for the PHP? Because PHP runs on Windows, you might consider trying it on Windows.
I have seen some problems with PSQL if it's prior to v9.5. I believe that PSQL links to older libraries but I don't have a Linux box to test and can't remember which ones.
__________________
Mirtheil Software
Certified Pervasive Developer
Certified Pervasive Technician
Custom Btrieve/VB development
http://www.mirtheil.com
I do not answer questions by email. Please post on the forum.
Reply With Quote
  #6 (permalink)  
Old 07-09-07, 06:17
johnnytang24 johnnytang24 is offline
Registered User
 
Join Date: Jun 2007
Posts: 6
No, Linux is not a requirement for PHP, but there are a large amount of external programs called from PHP that make a switch to Windows unfeasible.

Perhaps an upgrade to v9.50 is in order.

Thanks.
Reply With Quote
  #7 (permalink)  
Old 07-09-07, 07:00
johnnytang24 johnnytang24 is offline
Registered User
 
Join Date: Jun 2007
Posts: 6
Ok, I tried upgrading PSQL to version 9.50.077.002 on a test machine, but I still get the same core dump.

Thanks.
Reply With Quote
  #8 (permalink)  
Old 11-29-07, 01:02
Skeeter Skeeter is offline
Registered User
 
Join Date: Nov 2007
Posts: 3
That worked for me but...

Mirtheil

That sample worked great for me but I get an error at the bottom when I run it from the browser:

Error in my_thread_global_end(): 1 threads didn't exit

It appears at the very bottom after the "Number of Fields: 10". Any ideas?
Reply With Quote
  #9 (permalink)  
Old 11-29-07, 08:56
mirtheil mirtheil is offline
Registered User
 
Join Date: Dec 2001
Posts: 1,026
Haven't seen that error before. A quick Google search for "my_thread_global_end()" shows that this is a bug in MySQL. If you've got MySQL enabled in the PHP.INI, you might try disabling it to see if the error goes away.
__________________
Mirtheil Software
Certified Pervasive Developer
Certified Pervasive Technician
Custom Btrieve/VB development
http://www.mirtheil.com
I do not answer questions by email. Please post on the forum.
Reply With Quote
  #10 (permalink)  
Old 11-29-07, 11:35
Skeeter Skeeter is offline
Registered User
 
Join Date: Nov 2007
Posts: 3
MySQL Bug

Mirtheil,

Yes, that fix the error. I guess we just have to wait until PHP fixes the bug.

Thanks for your assistance!


Skeeter
Reply With Quote
  #11 (permalink)  
Old 11-29-07, 11:41
mirtheil mirtheil is offline
Registered User
 
Join Date: Dec 2001
Posts: 1,026
__________________
Mirtheil Software
Certified Pervasive Developer
Certified Pervasive Technician
Custom Btrieve/VB development
http://www.mirtheil.com
I do not answer questions by email. Please post on the forum.
Reply With Quote
  #12 (permalink)  
Old 11-29-07, 11:49
Skeeter Skeeter is offline
Registered User
 
Join Date: Nov 2007
Posts: 3
My installed version is 5.2.5 and if I understand correctly I need to replace my ddl with a previous version's dll, correct?

Thanks!

Frank
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On