0

hello this is my code :

<?

$DBNAME='astbase.db';
$MYTABLE ='extens';

$wsdl = "wwwwww";
$reply = "wwww";
$idsms = "4";
$exten = 100;

$base= new PDO('sqlite:'.$DBNAME);//, 0666, $err);
$query = "CREATE TABLE IF NOT EXISTS $MYTABLE(id INTEGER PRIMARY KEY,exten VARCHAR(255), wsdl TEXT, reply text, idsms INTEGER)";    
$results = $base->exec($query);
print_r($results);

$query = "INSERT INTO $MYTABLE(id,exten,wsdl,reply,idsms) VALUES(NULL,'$exten','$wsdl','$reply',$idsms)";
$results = $base->exec($query);
print_r($results);

?>

when i execute the script in the command line (php5 script.php), it works fine , but when i run it with the web browser, only the first statement is executed !!! what's wrong ??

thanks

1 Answer 1

1

You should

  • check your PHP error log file
  • call the sqlite_last_error() function just after your first statement (manual)

I'm guessing it is a permissions issue, i.e. your webserver does not have the right to write in the directory where your sqlite database file is located.

It works with the command line because it uses your own user's rights (whereas in the browser it uses Apache's user, which often has less rights).

Sign up to request clarification or add additional context in comments.

1 Comment

yes thanks, it's permissions problem, i set the file database to 777 but the directory didn't allow public access, i added the user www-data (apache user) to the owner group and it's working, thank you :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.