Read/write SQLite 3.x files in PHP 5???
Posted: Wed Aug 23, 2006 6:52 pm
I have installed Apache 2.2.2 and PHP 5.1.4 on a Mac OS 10.4.7 computer. My main reason for this installation is to serve up dynamic web pages with SQLite data that I create with REALbasic in the most current version. (The same problem occurs when I use SQLite files created with SQLite Database Browser 1.2.1, the terrific open-source app.)
I'm new to PHP so I'm probably making a simple mistake, but a seemingly trivial program produces fatal errors in trying to open a SQLite file. I have a sinking feeling that the problem might be different incarnations of SQLite. The version that apparently comes prepackaged with PHP 5 is SQLite 2.8, but I believe REALbasic uses SQLite 3 something.
In any event, here's the error message:
Warning: sqlite_open() [function.sqlite-open]: unable to open database: /test_data/Yields.rsd in /Library/WebServer/Documents/tyields.php
Here's the code snippet that fails on the line with $db:
The database called Yields.rsd was created with SQLite and even when I remove the file from the test_data directory I get the same error when I believe the correct behavior ought to be creation of the database in lieu of opening an existing one.
Any ideas about what might be amiss? Are there any PHP experts around who have sample code from which we might learn? Thanks in advance.
I'm new to PHP so I'm probably making a simple mistake, but a seemingly trivial program produces fatal errors in trying to open a SQLite file. I have a sinking feeling that the problem might be different incarnations of SQLite. The version that apparently comes prepackaged with PHP 5 is SQLite 2.8, but I believe REALbasic uses SQLite 3 something.
In any event, here's the error message:
Warning: sqlite_open() [function.sqlite-open]: unable to open database: /test_data/Yields.rsd in /Library/WebServer/Documents/tyields.php
Here's the code snippet that fails on the line with $db:
Code: Select all
<html>
<body>
<?php
$db = sqlite_open("/test_data/Yields.rsd");
$query = "SELECT * FROM YieldData";
$result = sqlite_query($db,$query) or die("Query failed: ".sqlite_error());
$row = sqlite_fetch_array($result);
while($row=sqlite_fetch_array($result))
{
foreach($row as $value)
{
echo "$value<br>";
}
}
sqlite_close($db);
?>
</body>
</html>The database called Yields.rsd was created with SQLite and even when I remove the file from the test_data directory I get the same error when I believe the correct behavior ought to be creation of the database in lieu of opening an existing one.
Any ideas about what might be amiss? Are there any PHP experts around who have sample code from which we might learn? Thanks in advance.