[Fri Feb 22 12:54:15 2008] [error] [client 132.64.4.16] PHP Warning: odbc_exec() [function.odbc-exec]: SQL error: [unixODBC][FreeTDS][SQL Server]Could not find stored procedure 'SHOW'., SQL state 37000 in SQLExecDirect in /srv/www/htdocs/hu/Proj1/test.php on line 9
[Fri Feb 22 12:54:15 2008] [error] [client 132.64.4.16] PHP Warning: odbc_fetch_row(): supplied argument is not a valid ODBC result resource in /srv/www/htdocs/hu/Proj1/test.php on line 10
[Fri Feb 22 12:54:15 2008] [error] [client 132.64.4.16] PHP Warning: odbc_free_result(): supplied argument is not a valid ODBC result resource in /srv/www/htdocs/hu/Proj1/test.php on line 14
The test source program is:
--- begin odbctest.php---
<?
// connect to DSN MSSQL with a user and password
$connect = odbc_connect("DSNNAME", "user", "passwd") or die
("couldn't connect");
print "connection ok";
odbc_exec($connect, "use SwitchCenterDB");
print "SwitchCenterDB ok";
$result = odbc_exec($connect, "SHOW TABLES");
while(odbc_fetch_row($result)){
print(odbc_result($result, "CompanyName") .
' ' . odbc_result($result, "ContactName") . "\n");
}
odbc_free_result($result);
odbc_close($connect);
?>
--- end odbctest.php --
__________________________
Subscribe now!
The Latest
Featured Videos
Linux Journal Live - eBook Readers and DRM
November 14th, 2008 by Shawn Powers in
The November 13, 2008 edition of Linux Journal Live! Shawn Powers and special guest, Linux Journal Author Daniel Bartholomew, talk e-book readers and Daniel's Kindle, DRM, and other goodness.
Run Your Windows Partition Without Rebooting
November 13th, 2008 by Elliot Isaacson in
Dual booting is a necessary evil and very inconvenient. What if you could run your windows partition in a virtual machine, so you wouldn't have to worry about rebooting anymore? With VMWare Workstation, you can.
Recently Popular
From the Magazine
December 2008, #176
The Oxford English Dictionary says the word "gadget" is a placeholder name for a technical item whose precise name one can't remember. Like that book-reader thingy from Amazon...what's it called? Spindle, Gindle...Kindle, that's it. Check it out in this month's gadget issue.
Other gadgets covered include the Nokia tablets, the BlackBerry, the Neo FreeRunner, the Dash Express, the Roku Netflix Player, the Kangaroo TV, The TomTom GO 930 and the MooBella Ice Cream System. On the larger hardware front, read the reviews of the Acer Aspire One and the YDL PowerStation. On the software front, check out the articles and columns on memcached, Samba security, Mutt, desktop gadgets, bash and Puppet. To wrap it all up, read Doc's thoughts on Google and the browser platform.
Delicious
Digg
Reddit
Newsvine
Technorati







Bad SQL
On March 1st, 2008 paul.bohme says:
The first error is the real one: You're feeding it something it doesn't know how to deal with. A bit of googling comes up with 'show tables' being a MySQL-ism - not something SQL Server is going to understand.
The other errors come from not checking the result set before trying to use it. ;-)
I am by no means an expert
On February 25th, 2008 Mike Roberts says:
I am by no means an expert on your topic but something did catch my eye. The line in your sample code:
print(odbc_result($result, "CompanyName") .
' ' . odbc_result($result, "ContactName") . "\n");
appears to me to have an extra ) between "\n" and the ;
Just a guess but if that is really in the code that could be all or part of the problem.
Happy hunting!
__________________________Mike Roberts is a bewildered Linux Journal Reader Advisory Panelist.
Post new comment