Reputation: 13
I have Apache web server installed on Manjaro(Sway) linux, and default location of projects is:
/srv/http/
I have created a folder for my project by the name test
in the location and have created a database named db1.db
inside it through terminal using the following steps (followed this article):
sqlite3 db1
sqlite> create table tblone(one varchar(10), two smallint);
sqlite> insert into tblone values('helloworld',20);
sqlite> insert into tblone values('linux', 30);
I can verify that the table has been created successfully by running the following command:
sqlite> select * from tblone;
which outputs:
helloworld|20
linux|30
I need to create a PHP file which connects the above created database using PDO.
So, inside test
folder, I create a file index.php
with the following content:
<?php
$myPDO = new PDO('sqlite:test/db1.db');
$result = $myPDO->query("SELECT * FROM tblone");
foreach($result as $row){
echo $row['one']. "\n";
}
?>
But I get a blank white screen in output, when I enter http://localhost/test/index.php
in browser. Where am I going wrong?
Upvotes: 1
Views: 64