Page 1 of 1

[SOLVED] php5/sqlite hanging death

Posted: Sat Jul 24, 2004 6:39 pm
by brandan
i'm having a strange issue with php5. i am running freebsd 5.2.1 and apache 1.3.29. i have download php5-cli via pkg_add so that i can run scripts in a terminal window.

i want to run scripts in a terminal window because a site engine (backend and frontend) that i want to use needs to be setup using php -f. the setup ran without problems on a computer running windows 2000, but on freebsd it doesn't pan out too well.

it seems to be a permissions issue, but what is strange is that the scripts have an option to die with an error message if any problems are encountered, however the script just exits without even continuing through to the next lines. here is the .phps script that regulates the setup:

Code: Select all

<?php
require_once('functions.phps');

print("Running database schema setup utility\n");
print("WARNING: All existing data will be lost!\n");

countdown(10);
include_config('config.phps', 'config-example.phps');
check_php_version('5.0.0');
$database = sqlite_open_db(DATABASE_PATH);
sqlite_check_writable($database);
sqlite_drop_tables($database);
sqlite_schema_setup($database, DATA_PATH . 'core-create.sql');
sqlite_close_db($database, DATABASE_PATH);

print("The command completed successfully!\n");
?>
as soon as any of the functions that deal with sqlite writing to a database (sqlite_checkwritable, for instance, which attempts to create a 'test' table) the script dies without any message, though the functions are set to relay messages upon error. just as an example, here is one of the functions:

Code: Select all

function sqlite_check_writable($database) {

	print("* Checking if SQLite database is writable: ");

	$table = 'test_' . date('YmdHis');
	if (@sqlite_exec($database, sprintf("begin; create table %s (id); drop table %s; commit;", $table, $table))) {
		print("Okay\n");
	}

	else {
		print("Failed\n");
		die($php_errormsg . "\n");
	}
}
here is the output from the failed setup:

raindogs# php -f utils/db_schema_setup.phps
Running database schema setup utility
WARNING: All existing data will be lost!
* Checking for config file (config.phps): Failed
* Checking for default config file (config-example.phps): Okay
* Checking for PHP version >= 5.0.0: Okay
* Opening SQLite database (resources/core_data/core.sqlite): Okay
* Checking if SQLite database is writable: raindogs#

it SEEMS like a permissions issue, but i don't see how this can be possible considering i've run the script as root and with full permissions to every user.

does anybody have any experience with php5 on freebsd 5.2.1? perhaps i should revert to an older (stable) release?

Posted: Wed Jul 28, 2004 5:22 am
by brandan
it had to do with sqlite_exec not being recognized as a function. i had to use sqlite_query instead.

what is strange is that sqlite_exec is the 'preferred' form of querying the database. oh well.

Posted: Fri Jul 30, 2004 3:14 pm
by brandan
actually the problem lied within the freebsd 5.2.1 php 5.0.0 package not being compiled correctly (or having been an old version). i downloaded the php 5 source and compiled it myself and everythign worked beautiful (sqlite_exec was recognized!!).

the end result was getting the gyrator engine running on http://www.raindogs.co.uk. i am the champion!!!!11