Answer the question
In order to leave comments, you need to log in
How to create a SQLITE database server and how to connect to it using PHP PDO?
Hello! I've been struggling with this code for 2 days now:
$db = new PDO('sqlite:/tmp/restaurant.db'); //(1)
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$q = $db->exec("CREATE TABLE dishes (
dish_id INT,
dish_name VARCHAR(255)
)");
?>
Answer the question
In order to leave comments, you need to log in
My advice:
Install MySQL, and in all examples replace:
to the line suggested by OKyJIucT :
<?php
$db = 'dbname'; // Название БД MySQL
$user = 'user'; // Юзер
$pass= 'password'; // пароль
$db = new PDO("mysql:host=localhost;dbname=$db", $user, $pass);
?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question