i want to disply the database content on webbrowser . The program writeen syntax free but it can not display anything on web browser
why ?
i can use the MS Access 2000 database

plz help me

code is ..


#!usr/bin/perl
use Win32::OLE;
use Win32::OLE::Const 'Microsoft ActiveX Data Objects';

$table = "emptable";
$conn = Win32::OLE->new("ADODB.Connection");
$rs = Win32::OLE ->new("ADODB.Recordset");
$conn->Open("emptable");

print "Content-type:text/html \n\n";
print "<div align = center> <font face = verdana color=#333399 size = 5> Address Book </font><br><br>";
print "<table bgcolor =lightyellow><tr><th width=150 align = left>First Name</th>";
print "<th width = 150 align= left>Last Name</th><th width=150 align=left>Address</th></tr>";

$sql = "select firstname,lastname, address from $table";
$rs->Open($sql,$conn,1,1);
while(! $rs->EOF)
{
$firstname = $rs->Fields('firstname')->value;
$lastname = $rs->Fields('lastname')->value;
$address = $rs->Fields('Address')->value;
print "<tr><td>$firstname</td><td>$lastname</td><td>$Address</td></tr>";
$rs->MoveNext;
}

print "</table></div>";
$rs->Close;
$conn->Close;

Well, I see no <HTML> </HTML> or <BODY> </BODY> tags, so, if that is suppossed to be a complete HTML document, it is not.

I, myself, don't know how those OLE packages are suppossed to work, so I can't even begin to say whether this tip is correct or not.

All I can say, is, that if this is suppossed to be a complete HTML document it is not.

i want to disply the database content on webbrowser . The program writeen syntax free but it can not display >>>anything on web browser
why ?

First thing I want to ask you where in the code you have specified the Database(for eg: MS Access or MySQL etc..). Where have specified the path to database.

You can provide all these information in single go, by creating DSN(Data Source Name).
I have used the ODBC drive to access the database values.

  1. Create DSN for yur database.

    How(if you are using WinXP then...):
    Go to Control Panel--Administrative Tools--Data Sources (ODBC)
    You get a window then, select System DSN so that you can access your database through Apache/Webserver select 'System DSN' tab then click on 'Add' button, scroll down you'll find 'Microsoft Access Driver(*.mdb)', select and say ok, you are then prompted to enter the DSN (you can leave description...), select database file. So your DSN is got created.

i can use the MS Access 2000 database

  1. How to acccess the database.
    Then you can follow this eg. program...
#Use ODBC driver instead
use Win32:ODBC;

my $db = new Win32::ODBC('your_DSN');# <-- here goes your DSN

if(!$db)
{
    print "Cannot find the DATABASE";
}

my @tables = $db->TableList();
print join(" ", @tables);
my $q = "select * from USER_TABLE where USR='test'";
$db->Sql($q);
while($db->FetchRow)
{
    my $k = $db->Data();
    print "\n\n".$k;
}

exit(0);

Note:
When you want access the database through the web then you have to create System DSN. If you want to access your database then you can create User DSN/System DSN.

kath.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.