PHP ODBC Connection not pulling results

I'm new to Sage and ODBC connections in general, so I'm looking for a bit of help here.  I have set up a System DSN on the server, and am able to get a successful connection using PHP.  However, whenever I try to run any sort of query, it doesn't pull any results.  

Here is some code I'm working with to try and get something to display.  I do get the "Connection is successful" message, but nothing after that.   Please help!!!!

$rConn = odbc_connect("SageODBC", MyUsername, MyPassword);

if (!$rConn) {
die('Unable to connect to the Sage datasource.');
}
else
{
echo "Connection is successful<br />";

$result = odbc_tables($rConn);

$tables = array();
while (odbc_fetch_row($result))
array_push($tables, odbc_result($result, "TABLE_NAME") );

foreach( $tables as $t ) {
echo "$t\n";
}

}

Parents
  • Just tried your code on my system and it worked fine. Only difference is my connect string

    $rConn = odbc_connect("DSN=systemdsn;", "usr", "pwd") ;

    But if you are getting a connection, that shouldn't be it.

    I am running from a browser so I changed the  echo "$t<br>";  and got a nice long list of table names.

  • in reply to Dain

    If I add in the "DSN=" it gives me the Unable to Connect error message.  I'm truly stumped.  Not sure why this code isn't working on my end.  Are there any specific settings in the php.ini file that need to be set?  Or any of the System DSN settings that need to be set?

Reply
  • in reply to Dain

    If I add in the "DSN=" it gives me the Unable to Connect error message.  I'm truly stumped.  Not sure why this code isn't working on my end.  Are there any specific settings in the php.ini file that need to be set?  Or any of the System DSN settings that need to be set?

Children