I have two pages, one in php (index.php) and the other in Perl (dbcon.pl).
Basically, I want only the user interface to be displayed in my php file, and all data operations should be performed in the Perl file.
I tried in index.pl
<?php include("dbcon.pl");?>
<html>
<br/>PHP</br>
</html>
and dbcon.pl has
use strict;
use warnings;
use DBI;
use CGI::Simple;
my $cgi = CGI::Simple->new;
my $dsn = sprintf('DBI:mysql:database=%s;host=%s','dbname','localhost');
my $dbh = DBI->connect($dsn,root =>'',{AutoCommit => 0,RaisError=> 0});
my $sql= "SELECT * FROM products";
my $sth =$dbh->prepare($sql);
$sth->execute or die "SQL Error: $DBI::errstr\n";
while (my @row = $sth->fetchrow_array){
print $cgi->header, <<html;
<div> @row[0] @row[1] @row[2] @row[3] @row[4]</div>
html
}
but when I run index.php in the browser, it prints all the code in the dbcon.pl file instead of executing it
How to solve this problem?
note: i run this on windows environment
is there any other way to do this?
source
share