PHP to Connect to Pervasive SQL

I have some PhP code to connect to a Pervasive SQL database but it is not working.
See code and screenshots of the Pervasive SQL Drivers as well as the Database ODBC details.
I need help in finding the problem why my script is not working


//$connect=odbc_connect("Driver={Pervasive ODBC Interface};ServerName=localhost;ServerDSN=P000Lap;","", "", SQL_CUR_USE_ODBC);

//$connect=odbc_connect("Driver={Pervasive ODBC Engine Interface};ServerName=localhost;ServerDSN=P000Lap;","", "", SQL_CUR_USE_ODBC);

$connect=odbc_connect("Driver={Pervasive ODBC Client Interface};ServerName=localhost;ServerDSN=P000Lap;","", "", SQL_CUR_USE_ODBC);

//$connect = odbc_connect("DRIVER={Pervasive ODBC Engine Interface};ServerName=localhost;DNS=P000Lap;","","");

if(!$connect) die("Could not connect<br>");
else die('Connected');


I’m running Win7 64 and Pervasive Driver Ver10 for Client and Engine Interface

You might want to print the actual error for why you can’t connect rather that just a statement saying the same. Rather than die, use a try catch and allow the error to be thrown.

Wow - never knew that could be done. Sorry very new to php - can you help with the script? Else
I’ll see if Google is still my friend :slight_smile:

I tried this but got no result - like I said - it might take me longer to figure out how to do this :slight_smile:


//$connect=odbc_connect(“Driver={Pervasive ODBC Interface};ServerName=localhost;ServerDSN=P000Lap;”,"", “”, SQL_CUR_USE_ODBC);

//$connect=odbc_connect(“Driver={Pervasive ODBC Engine Interface};ServerName=localhost;ServerDSN=P000Lap;”,"", “”, SQL_CUR_USE_ODBC);

// $connect=odbc_connect(“Driver={Pervasive ODBC Client Interface};ServerName=localhost;ServerDSN=P000Lap;”,"", “”,

try {

$connect=odbc_connect(“Driver={Pervasive ODBC Interface};ServerName=localhost;ServerDSN=P000Lap;”,"", “”,
} catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), “\n”;

//$connect = odbc_connect(“DRIVER={Pervasive ODBC Engine Interface};ServerName=localhost;DNS=P000Lap;”,"","");

//if(!$connect) die(“Could not connect
//else die(‘Connected’);


Sponsor our Newsletter | Privacy Policy | Terms of Service