homepage Welcome to WebmasterWorld Guest from 54.166.8.138
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
php5 and sqlite set up
sqlite suddenly stopped working
CDNQuilter




msg:3361487
 9:00 pm on Jun 7, 2007 (gmt 0)

All of a sudden, my sqlite database application just stopped working with no error messages - the pages using sqlite just refused to load.

(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.

 

eelixduppy




msg:3361529
 9:36 pm on Jun 7, 2007 (gmt 0)

Sounds like an issue with the server and not the code. Not exactly sure what's going on. Have you tried getting any error messages from the database?

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... :)

CDNQuilter




msg:3361601
 11:02 pm on Jun 7, 2007 (gmt 0)

Thanks so much for replying!

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!

jatar_k




msg:3361651
 12:10 am on Jun 8, 2007 (gmt 0)

have you checked with your host to see if they upgraded anything?

often (not always by any means) this is because they upgrade and change settings and never mention it or just don't care if they botched it.

CDNQuilter




msg:3361772
 4:08 am on Jun 8, 2007 (gmt 0)

Yes, I have two emails in to their customer support but they have not yet responded.

CDNQuilter




msg:3362865
 3:09 pm on Jun 9, 2007 (gmt 0)

Just in case anyone is interested . . .

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.

jatar_k




msg:3362868
 3:18 pm on Jun 9, 2007 (gmt 0)

they should be concerned enough that they don't switch things without notifying their customers, if that is what happened.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved