Hey,
SQLite is not a server based Database and especially, it is not
MySQL. So using mysql_connect will not work. (And mysql_connect is
also deprecated for MySQL! Use
MySQLi or
PDO for
MySQL.) Depending on what PHP extensions are installed on your
server, you would need to use the SQLite3 extension or PDO to use an
SQLite3 Database.
In SQLite there is no server, you only need access to the database
file. So there also is no username or password. You just connect and
query the database like this:
Using SQLite3:
<?php
$db = new SQLite3('mysqlitedb.db3');
$results = $db->query('SELECT bar FROM foo');
while ($row = $results->fetchArray()) {
var_dump($row);
}
?>
mysqlitedb.db3 is the name of your database file (assuming it is in
the same directory, if not, add the path).
Source:
http://php.net/manual/en/sqlite3.query.php
Or using PDO:
<?php
$conn = new PDO("
sqlite:
mysqlitedb.db3
");
$sql = 'SELECT name, color, calories FROM fruit ORDER BY name';
foreach ($conn->query($sql) as $row) {
print $row['name'] . "\t";
print $row['color'] . "\t";
print $row['calories'] . "\n";
}
?>
Sources: http://php.net/manual/en/ref.pdo-sqlite.connection.php
http://php.net/manual/en/pdo.construct.php
http://php.net/manual/en/pdo.query.php
I hope this helps you to get stared.
Greetings,
Christopher