Damn Small Linux (DSL) Forums
Welcome,
Guest
. Please
login
or
register
.
May 31, 2023, 08:43:25 PM
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
News
The new DSL forums are now open.
Stats
11609
Posts in
311
Topics by
291
Members
Latest Member:
mik3ca
Search:
Advanced search
Get
The Official Damn Small Linux Book
.
Great VPS hosting provided by
Tektonic
Damn Small Linux (DSL) Forums
MyDSL Extensions
System
sqlite insert from php
« previous
next »
Pages:
[
1
]
Author
Topic: sqlite insert from php (Read 63296 times)
murdock
Newbie
Posts: 2
sqlite insert from php
«
on:
August 14, 2018, 03:55:57 PM »
Hello, I was installing dsl linux
with php connected to sqlite the topical sentences work
http://damnsmalllinux.org/static/act-Print/f-16/t-3036.html
but only for a php sqlite select
but to work with insert I get error
example:
index7.php
---------------
<html>
<head>
<title>DSL</title>
</head>
<body>
<h1>INSERT</h1>
<br><hr>
<form action="http://localhost/env.php" method="post">
<ul>
<li>Name: <input type="text" name="nombre" size="20"><br>
<li>Email: <input type="text" name="correo" size="20"><br>
<li>Web Site: <input type="text" name="web" size="20"><br>
<li>Comment: <input type="text" name="comm" size="20"><br>
</ul>
<input type="submit" value="Ok"><br>
<input type="reset" value="Delete"><br>
</form>
<hr>
</body>
</html>
env.php
-----------
<?php
require "sqlite.php";
$db = 'comment_section.db';
sqlite_connect($db) or die ("Could not connect");
$sql = "insert into comments(name,
email,
website_url,
comment ) values ('$_POST[nombre]',
'$_POST[correo]',
'$_POST[web]',
'$_POST[comm]' );
sqlite_query($sql, $db) or die (Query Failed);
?>
Result:
---------
________________________________________________________________________________
sqlite_exec: insert into comments(name, email, website_url, comment)values('pedro', 'pepe@mail.com',
'pepino.wordpress.com','viejo boludo' )
________________________________________________________________________________
________________________________________________________________________________
sqlite_query result:
SQL error: unable to open database file
SQL error: unable to open database file
SQL error: unable to open database file
________________________________________________________________________________
Query Failed
Logged
CNK
Sr. Member
Posts: 269
Re: sqlite insert from php
«
Reply #1 on:
August 14, 2018, 11:02:46 PM »
I've used PHP in DSL without trouble, but I haven't worked with SQLite. I notice that without having set anything up, it displays a "main" database with no file location when the ".databases" command is entered at the SQLite terminal. If you haven't set up your own separate database and were expecting to use the default, this might indicate that you need to set your own location for the database.
Otherwise it looks like some sort of permissions problem. Perhaps the SQLite process isn't running as root?
Logged
murdock
Newbie
Posts: 2
Re: sqlite insert from php
«
Reply #2 on:
August 17, 2018, 12:40:02 PM »
Ok I put the database in the same folder htdocs of the server monkey that is by default and how can I do to instantiate sqlite as root you know why I the sqlite file will generate it only with the word "sqlite databasename.db" and nothing else I do not know how to pass that file to root
Logged
CNK
Sr. Member
Posts: 269
Re: sqlite insert from php
«
Reply #3 on:
August 19, 2018, 12:36:39 AM »
As I said, I haven't set up SQLite myself. However if you're now using a database file that doesn't require root permissions to access, I imagine you shouldn't need to worry about running it as root.
For configuration information, I'd recommend reading the manual page:
https://linux.die.net/man/1/sqlite3
Of course a more complete guide will be the SQLite official documentation:
https://sqlite.org/docs.html
Logged
Pages:
[
1
]
« previous
next »
Jump to:
Please select a destination:
-----------------------------
Damn Small Linux
-----------------------------
=> Site News
=> Release Candidates
=> User Feedback
=> DSL Tips and Tricks
=> USB booting
=> DSL Ideas and Suggestions
=> DSL Embedded
=> HD Install
=> Laptops
=> Other Help Topics
-----------------------------
MyDSL Extensions
-----------------------------
=> The Testing Area
=> Apps
=> Games
=> Gtk2
=> Multimedia
=> Net
=> System
=> Themes
=> Window Managers
=> Extension Development
-----------------------------
DSL Not
-----------------------------
=> DSL-N
-----------------------------
Non-DSL Topics
-----------------------------
=> water cooler