Re: PHP und Freetds
"Thomas, Christopher (LLU)" <[email protected]>
| Newsgroups | gmane.comp.db.tds.freetds |
|---|---|
| Message-ID | <6B9B0CEF7F409D439E78288D8665BD8F341882@oakmont.llu.ad.lluahsc.org> |
Hello,
I have had trouble with the odbc_num_rows() function. It seems to always return -1 if you call it just after odbc_exec(). For me, it always returned the right value after I looped through all the results.(useless at that point)
Here is some peudo code that I use that works for me:
$connect = odbc_connect($dsn, $user, $passwd);
if ($connect > 0) {
print ("Connection ok\n");
}
$query = "select description from job where no_='20-100'";
$result = odbc_exec($connect, $query);
while (odbc_fetch_row($result)) {
$description = odbc_result($result, "description");
print($field1 . "\n");
}
odbc_free_result($result);
Since you only have one column in your select, you can't get two columns in the result. I hope this helps.
Chris
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Christian
Sent: Friday, March 21, 2008 1:46 AM
To: [email protected]
Subject: [freetds] PHP und Freetds
Hello
My Configuration
SUSE 10.3
PHP 5.2.4
Apache 2.0 Handler
Freetds 0.65 dev. 20070819-6.2
I need access to a MS SQL Server 2005 running under Windows 2003. I try it
with freetds and unixodbc
With ISQL on the commandline I get all Value out of the Database
For Example
Code:
isql -v srvsql 'Domain\username' password
Code:
select description from job where no_='20-100'
here I get the value of the field description
When I try it with php Code
PHP CODE:
<?php
$connect = odbc_connect("srvsql", "spirk\fic", "Zxpjr8tu");
if ($connect > 0) {
print ("Connection ok\n");
}
$query = "select description from job where no_='20-100'";
$result = odbc_exec($connect, $query);
echo odbc_num_rows($result);
# fetch the data from the database
while(odbc_fetch_row($result)) {
$field1 = odbc_result($result, 1);
$field2 = odbc_result($result, 2);
print("$field1 $field2\n");
}
?> when I start then php script on the bash
Code:
php -q dateiname.php
I get return the following message
Code:
Connection ok
-1
The value "-1" is the result of echo odbc_num_rows($result);
In short words
With ISQL I get all infos that I want, with php I get the name of the
tables, but no values in the tables.
Maybe someone has a solution why it work on the commandline (isql) and fails
with PHP.
Many thanks and a happy weekend
Christian
Mit freundlichen Grüßen
Fimberger Christian
SPIRK & PARTNER
Ziviltechnikergesellschaft m.b.H.
Bayerhamerstraße 14
A-5020 Salzburg
T +43 (0)662 64 20 12 - 239
F +43 (0)662 64 60 12
M +43 (0)699 16 64 20 39
e-mail: <mailto:[email protected]>
web: <http://www.spirk.at>
_______________________________________________
FreeTDS mailing list
[email protected]
http://lists.ibiblio.org/mailman/listinfo/freetds