Jump to content

Problems with odbc_exec and sybase


davemere

Recommended Posts

Hi y'all

 

I'll keep this simple! Here's my code:

 

$conn = odbc_pconnect("conn", "id", "pwd");

if (odbc_error()) { 	
echo "Connection failed <br>";  
exit;   
}
else {
echo "Connection successful";    
};

$qry = "SELECT count(*) FROM <table>";
$result = odbc_exec($conn, $qry);
echo odbc_result($result,1); 

 

Here's the result!

Connection successful

Warning: odbc_exec() [function.odbc-exec]: SQL error: [sybase][ODBC Driver]Optional feature not implemented, SQL state HYC00 in SQLSetStmtOption in C:\www\sybconnect-odbc.php on line 20

 

Warning: odbc_result(): supplied argument is not a valid ODBC result resource in C:\www\sybconnect-odbc.php on line 21

 

This should be so simple!! It can't be a code problem. Can anyone offer a hint as to what feature I'm missing?

 

thanks!

Link to comment
Share on other sites

Hi Dave, if the query is working, you can always mask that error and make it no longer show by using a magic little thing in php:

 

Just add a @ symbol before the query and you will no longer see that error. Please note however that although the error wont show, it doesn't mean it isn't still there :D

 

Shaun

Link to comment
Share on other sites

From the manual for odbc_error() - "This function returns meaningful value only if last odbc query failed." Calling odbc_error after the query might provide additional information about the connection.

 

You need to test the resource returned by the odbc_connect() to find if the connection worked.

 

Is the first parameter in your odbc_connect() the name of a DSN that you have setup?

Link to comment
Share on other sites

From the manual for odbc_error() - "This function returns meaningful value only if last odbc query failed." Calling odbc_error after the query might provide additional information about the connection.

odbc_error returns this message: [sybase][ODBC Driver]Optional feature not implemented

 

 

You need to test the resource returned by the odbc_connect() to find if the connection worked.

Sure. Does the following line not provide a test of the resource? How else might I do it if necessary?

$result = odbc_exec($conn, $qry)

 

 

Is the first parameter in your odbc_connect() the name of a DSN that you have setup?

Yes. It's the name of a ODBC data source, tested it with MS Access and it works

 

 

?????? I think I'm going to try java instead. PHP/Sybase is beginning to frustrate...

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.