Discussion:
Conexão adodb com SQL Server
Edson David
2014-04-01 12:07:35 UTC
Permalink
Guys, I'm trying to make the connection to the SQL Server database using adodb, but when I run the lines below, the page is blank, not returning any rows. The problem from what I dectetei, is when the connection attempt is made ​​with the server and the table data. 
Thank you in advance.

<?php
// Include the library
include('adodb/adodb.inc.php');
$conn = &ADONewConnection('mssql');
$conn->Connect('192.168.1.2:1433','','','siscom'); // Connection to the database
$sql = "SELECT * FROM agenda"; // Select the table columns calendar
$consulta = $conn->Execute($sql);
// Displaying Data
echo("<table width='250' border='1'>
        <tr>
            <td>ID</td>
            <td>Name</td>
        </tr>");

while(!$query->EOF) {
    echo("<tr>
            <td>" . $query->fields[0] . "</td>
            <td>" . $query->fields[1] . "</td>
          </tr>");
    $query->MoveNext(); 
}

// Number of table records 
$tot_register = $consulta->RecordCount();
echo("<tr><td colspan='2'> Total record (s): " . $tot_register . "</td></tr>");
echo("</table>");
Jim Giner
2014-04-01 14:10:26 UTC
Permalink
Guys, I'm trying to make the connection to the SQL Server database using adodb, but when I run the lines below, the page is blank, not returning any rows. The problem from what I dectetei, is when the connection attempt is made ​​with the server and the table data.
Thank you in advance.
<?php
// Include the library
include('adodb/adodb.inc.php');
$conn = &ADONewConnection('mssql');
$conn->Connect('192.168.1.2:1433','','','siscom'); // Connection to the database
$sql = "SELECT * FROM agenda"; // Select the table columns calendar
$consulta = $conn->Execute($sql);
// Displaying Data
echo("<table width='250' border='1'>
<tr>
<td>ID</td>
<td>Name</td>
</tr>");
while(!$query->EOF) {
echo("<tr>
<td>" . $query->fields[0] . "</td>
<td>" . $query->fields[1] . "</td>
</tr>");
$query->MoveNext();
}
// Number of table records
$tot_register = $consulta->RecordCount();
echo("<tr><td colspan='2'> Total record (s): " . $tot_register . "</td></tr>");
echo("</table>");
Try enabling php's error checking and see what it reveals.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Jim Lucas
2014-04-01 15:28:54 UTC
Permalink
Guys, I'm trying to make the connection to the SQL Server database using adodb, but when I run the lines below, the page is blank, not returning any rows. The problem from what I dectetei, is when the connection attempt is made ​​with the server and the table data.
Thank you in advance.
<?php
// Include the library
As the other Jim said, enable error reporting and display_errors and you might
get something. Be warned, if it a parse error that is causing this issue, you
will need to enable the above two settings in your php.ini file instead of
placing those options in your script.

What I do sometimes when doing the above it too much hassle is to remove the
all but the first line, then add back each line. Always keep an echo
'!done!'; at the end to make sure that the script is finishing. My guess is
going to be that it is something in your include'd file or the
adonewconnection() function call.
include('adodb/adodb.inc.php');
$conn = &ADONewConnection('mssql');
$conn->Connect('192.168.1.2:1433','','','siscom'); // Connection to the database
$sql = "SELECT * FROM agenda"; // Select the table columns calendar
$consulta = $conn->Execute($sql);
// Displaying Data
echo("<table width='250' border='1'>
<tr>
<td>ID</td>
<td>Name</td>
</tr>");
while(!$query->EOF) {
echo("<tr>
<td>" . $query->fields[0] . "</td>
<td>" . $query->fields[1] . "</td>
</tr>");
$query->MoveNext();
}
// Number of table records
$tot_register = $consulta->RecordCount();
echo("<tr><td colspan='2'> Total record (s): " . $tot_register . "</td></tr>");
echo("</table>");
--
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Mauricio Tavares
2014-04-01 16:10:56 UTC
Permalink
Post by Jim Lucas
Post by Edson David
Guys, I'm trying to make the connection to the SQL Server database using
adodb, but when I run the lines below, the page is blank, not returning any
rows. The problem from what I dectetei, is when the connection attempt is
made with the server and the table data.
Thank you in advance.
<?php
// Include the library
As the other Jim said, enable error reporting and display_errors and you
might get something. Be warned, if it a parse error that is causing this
issue, you will need to enable the above two settings in your php.ini file
instead of placing those options in your script.
What I do sometimes when doing the above it too much hassle is to remove the
all but the first line, then add back each line. Always keep an echo
'!done!'; at the end to make sure that the script is finishing. My guess is
I myself am not a great php programmer, so I try to use the "or
die()" thingie (kinda like try/except in python?) so I know a given
statement worked or went boink. For instance, if it did not connect to
the database, why continue?
Post by Jim Lucas
going to be that it is something in your include'd file or the
adonewconnection() function call.
Post by Edson David
include('adodb/adodb.inc.php');
$conn = &ADONewConnection('mssql');
$conn->Connect('192.168.1.2:1433','','','siscom'); // Connection to the database
$sql = "SELECT * FROM agenda"; // Select the table columns calendar
$consulta = $conn->Execute($sql);
// Displaying Data
echo("<table width='250' border='1'>
<tr>
<td>ID</td>
<td>Name</td>
</tr>");
while(!$query->EOF) {
echo("<tr>
<td>" . $query->fields[0] . "</td>
<td>" . $query->fields[1] . "</td>
</tr>");
$query->MoveNext();
}
// Number of table records
$tot_register = $consulta->RecordCount();
echo("<tr><td colspan='2'> Total record (s): " . $tot_register . "</td></tr>");
echo("</table>");
--
Jim Lucas
http://www.cmsws.com/
http://www.cmsws.com/examples/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Jim Lucas
2014-04-01 16:17:57 UTC
Permalink
Post by Mauricio Tavares
Post by Jim Lucas
Post by Edson David
Guys, I'm trying to make the connection to the SQL Server database using
adodb, but when I run the lines below, the page is blank, not returning any
rows. The problem from what I dectetei, is when the connection attempt is
made with the server and the table data.
Thank you in advance.
<?php
// Include the library
As the other Jim said, enable error reporting and display_errors and you
might get something. Be warned, if it a parse error that is causing this
issue, you will need to enable the above two settings in your php.ini file
instead of placing those options in your script.
What I do sometimes when doing the above it too much hassle is to remove the
all but the first line, then add back each line. Always keep an echo
'!done!'; at the end to make sure that the script is finishing. My guess is
I myself am not a great php programmer, so I try to use the "or
die()" thingie (kinda like try/except in python?) so I know a given
statement worked or went boink. For instance, if it did not connect to
the database, why continue?
This method does work with 99% of all problems. But, if you have a parse
error, it will not work. Parse errors are a fatal error. It can't even
complete parsing your script, so it never fires that "or die();" call.
Post by Mauricio Tavares
Post by Jim Lucas
going to be that it is something in your include'd file or the
adonewconnection() function call.
Post by Edson David
include('adodb/adodb.inc.php');
$conn = &ADONewConnection('mssql');
$conn->Connect('192.168.1.2:1433','','','siscom'); // Connection to the database
$sql = "SELECT * FROM agenda"; // Select the table columns calendar
$consulta = $conn->Execute($sql);
// Displaying Data
echo("<table width='250' border='1'>
<tr>
<td>ID</td>
<td>Name</td>
</tr>");
while(!$query->EOF) {
echo("<tr>
<td>" . $query->fields[0] . "</td>
<td>" . $query->fields[1] . "</td>
</tr>");
$query->MoveNext();
}
// Number of table records
$tot_register = $consulta->RecordCount();
echo("<tr><td colspan='2'> Total record (s): " . $tot_register . "</td></tr>");
echo("</table>");
--
Jim Lucas
http://www.cmsws.com/
http://www.cmsws.com/examples/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Jim Giner
2014-04-01 16:18:36 UTC
Permalink
Post by Mauricio Tavares
Post by Jim Lucas
Post by Edson David
Guys, I'm trying to make the connection to the SQL Server database using
adodb, but when I run the lines below, the page is blank, not returning any
rows. The problem from what I dectetei, is when the connection attempt is
made with the server and the table data.
Thank you in advance.
<?php
// Include the library
As the other Jim said, enable error reporting and display_errors and you
might get something. Be warned, if it a parse error that is causing this
issue, you will need to enable the above two settings in your php.ini file
instead of placing those options in your script.
What I do sometimes when doing the above it too much hassle is to remove the
all but the first line, then add back each line. Always keep an echo
'!done!'; at the end to make sure that the script is finishing. My guess is
I myself am not a great php programmer, so I try to use the "or
die()" thingie (kinda like try/except in python?) so I know a given
statement worked or went boink. For instance, if it did not connect to
the database, why continue?
Post by Jim Lucas
going to be that it is something in your include'd file or the
adonewconnection() function call.
Post by Edson David
include('adodb/adodb.inc.php');
$conn = &ADONewConnection('mssql');
$conn->Connect('192.168.1.2:1433','','','siscom'); // Connection to the database
$sql = "SELECT * FROM agenda"; // Select the table columns calendar
$consulta = $conn->Execute($sql);
// Displaying Data
echo("<table width='250' border='1'>
<tr>
<td>ID</td>
<td>Name</td>
</tr>");
while(!$query->EOF) {
echo("<tr>
<td>" . $query->fields[0] . "</td>
<td>" . $query->fields[1] . "</td>
</tr>");
$query->MoveNext();
}
// Number of table records
$tot_register = $consulta->RecordCount();
echo("<tr><td colspan='2'> Total record (s): " . $tot_register . "</td></tr>");
echo("</table>");
--
Jim Lucas
http://www.cmsws.com/
http://www.cmsws.com/examples/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Yes - but even that can fail you if a syntax error occurs prior to it
and causes the script to stop or never even begin. The kind of coding
you mention is a necessary and proper thing but during development one
should always have error checking turned on to catch those nasty little
glitches that occur constantly.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Loading...