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.