Forum Moderators: coopster
(I don't know how long ago it stopped working - I haven't worked on this site for a long time and my error handler didn't send any messages because the pages just will not load.)
All I get is either a blank page(FF) or the message "Internet Explorer cannot display the webpage"
After trying everything I could think of for a few hours, I finally just tried to create a SIMPLE database and it appears that none of the php sqlite function calls are working, except for the sqlite_open() function.
The following code actually creates foo.db as expected but the sqlite_query() functions do not execute and the page does not load.
<?php
echo 'Test<br />';
$dbFile = 'foo.db';
unlink($dbFile);
$dbhandle = sqlite_open($dbFile, 0666, $sqliteerror);
sqlite_query($dbhandle,"CREATE TABLE foo (bar varchar(10))",$sqliteerror);
sqlite_query($dbhandle, "INSERT INTO foo VALUES ('fnord')",$sqliteerror);
$result=sqlite_query($dbhandle, 'SELECT bar FROM foo',$sqliteerror);
$values = sqlite_fetch_array($result);
echo '$values = ';
foreach($values as $value){
echo $value.'<br/>';
}
?>
When I execute phpinfo(), the sqlite info is:
PDO drivers sqlite2, sqlite
pdo_sqlite
PDO Driver for SQLite 3.x
PECL Module version
(bundled) 1.0.1 $Id: pdo_sqlite.c,v 1.10.2.6.2.2 2007/03/23 14:30:00 wez Exp $
SQLite Library 3.3.16
so it appears to be implemented. The last php build at this host was May 11 2007
This is about as far as my knowledge will take me in diagnosing this problem - I am a relative novice at sqlite but my little application was working just fine a few months ago.
From the symptom of the page not loading, I can only deduce that control is never returned from the call to sqlite_query().
I have an email into the support folks at this host but they have not been the brightest in the past so I am wondering if anyone here can shed any light on my problem.
Thanks in advance.
ps
I tried this identical code on one of my customer's sites (different hosting company) and it worked as expected.
So I copied the foo.db over to my host but I could not run any queries against it.
Try using something like this:
echo [url=http://www.php.net/manual/en/function.sqlite-error-string.php]sqlite_error_string[/url]([url=http://www.php.net/manual/en/function.sqlite-last-error.php]sqlite_last_error[/url]($dbhandle));
See what this gets us... :)
Yes, I posted the super-simplified code (that worked at one host) but before I posted here, I had run the code with lots of error checking. I was hoping that your error check would give more info but it doesn't.
Just creating the db file works fine:
<?php
if(!function_exists("debug")){
function debug($varname,&$v){
// debug('$var',$var);
if (isset($v)){
print("<pre><b>$varname = </b>");
if($printable = print_r($v,TRUE) )echo $printable;
else var_dump($v);
print '</pre>';
}
else print("<pre><b>$varname not set.</pre></b>");
return;
}}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<title>test.php</title>
</head>
<body>
<?php
echo 'Test<br />';
$dbFile = 'foo.db';
unlink($dbFile);
$dbhandle = sqlite_open($dbFile, 0666, $sqliteerror);
echo '<b>sqlite_last_error</b> '.sqlite_error_string(sqlite_last_error($dbhandle));
debug('$dbhandle',$dbhandle);
debug('$sqliteerror',$sqliteerror);
/*
Comment out the rest of it
sqlite_query($dbhandle,"CREATE TABLE foo (bar varchar(10))",$sqliteerror);
echo '<b>sqlite_last_error</b> '.sqlite_error_string(sqlite_last_error($dbhandle));
debug('$sqliteerror',$sqliteerror);
sqlite_query($dbhandle, "INSERT INTO foo VALUES ('fnord')",$sqliteerror);
$result=sqlite_query($dbhandle, 'SELECT bar FROM foo',$sqliteerror);
$values = sqlite_fetch_array($result);
echo '$values = ';
foreach($values as $value){
echo $value.'<br/>';
}
*/
?>
</body>
</html>
gives:
Test
sqlite_last_error not an error
$dbhandle = Resource id #2
$sqliteerror not set.
Which is just fine but when I un-comment only one sqllite_query() call
i.e.
<?php
if(!function_exists("debug")){
function debug($varname,&$v){
// debug('$var',$var);
if (isset($v)){
print("<pre><b>$varname = </b>");
if($printable = print_r($v,TRUE) )echo $printable;
else var_dump($v);
print '</pre>';
}
else print("<pre><b>$varname not set.</pre></b>");
return;
}}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<title>test.php</title>
</head>
<body>
<?php
echo 'Test<br />';
$dbFile = 'foo.db';
unlink($dbFile);
$dbhandle = sqlite_open($dbFile, 0666, $sqliteerror);
echo '<b>sqlite_last_error</b> '.sqlite_error_string(sqlite_last_error($dbhandle));
debug('$dbhandle',$dbhandle);
debug('$sqliteerror',$sqliteerror);
sqlite_query($dbhandle,"CREATE TABLE foo (bar varchar(10))",$sqliteerror);
echo '<b>sqlite_last_error</b> '.sqlite_error_string(sqlite_last_error($dbhandle));
debug('$sqliteerror',$sqliteerror);
/*
Comment out the rest of it
sqlite_query($dbhandle, "INSERT INTO foo VALUES ('fnord')",$sqliteerror);
$result=sqlite_query($dbhandle, 'SELECT bar FROM foo',$sqliteerror);
$values = sqlite_fetch_array($result);
echo '$values = ';
foreach($values as $value){
echo $value.'<br/>';
}
*/
?>
</body>
</html>
The page will not load so I cannot see what the error is.
I am really tearing my hair out here,that's for sure!
I broke down my test script more and determined that when I called the sqlite_query() function with too few parameters, php gave me the expected error messages. However, when I called it legitimately, the web page would not load.
Finally phoned my hosting company and they opened a ticket. (Had to phone as my emails are unanswered so far)
With my cheap hosting plan I don't expect support miracles. On the other hand, I would hope they would be concerned about other customers too.
What do folks here think? Is sqlite widely used enough that they should be concerned?
I'm using it for a VERY simple application to maintain time-sensitive information.