search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

How to execute using MySQL instead of SQLite?

Related article: HTML5 Doctor Appointment Scheduling (JavaScript/PHP/MySQL)
Asked by Saashu
2 years ago.

Hi, I tried executing this project and succeeded in doing so using SQLite. It was working perfectly fine. But when I tried using MySQL in WAMP, it was displaying fatal error in 'Doctor' tab and grid was not loading in 'Manager' tab. However, it was displaying normal in 'Patient' tab.
1. I followed your instructions and changed database connection settings username(as 'root') and password(as blank) details in _db.php file.
2. My localhost is working on port 80, so I changed that bit too (Am I supposed to do so?).
3. And there are tiny changes like deleting one ' at the end of $db->exec("CREATE DATABASE IF NOT EXISTS '$database' ' "); and $db->exec("use '$database' ' "); as I thought they were extra.
I google-d the error and changed key_buffer_size and max_allowed_packet values at C:\wamp64\bin\mysql\mysql5.7.14\my.ini.
I also attached the error screen shot for your reference. Could you please tell me where I am going wrong.

Answer posted by Dan Letecky [DayPilot]
2 years ago.

The default MySQL port is 3306 so keep that value (unless you have changed the port in your MySQL installation).

As far as I can see there are no extra backticks in the SQL commands. Your _db.php should start like this:

<?php

// this should point to your MySQL server instance:
$host = "127.0.0.1";
$port = 3306;
$username = "root";
$password = "";
$database = "doctor";

$db = new PDO("mysql:host=$host;port=$port",
               $username,
               $password);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

// other init
date_default_timezone_set("UTC");
session_start();

$db->exec("CREATE DATABASE IF NOT EXISTS `$database`");
$db->exec("use `$database`");
This question is more than 6 months old and has been closed. Please create a new question if you have anything to add.