Reputation: 186
I am having trouble testing out this connection, i'm trying to put a test value into the table.
Please take note:
<?php
$dsn = 'mysql:host=localhost:1842;dbname=mesimot;charset=utf8';
$db = new PDO($dsn, 'root', '');
$sql = "INSERT INTO mesima VALUES ('', 'first task','0')";
$count = $db->exec($sql);
if($count){
echo 'updated!' . '<hr>';
}
im running login.php on phpstorm and nothing really happens and I check the table and its still empty. Anything i'm missing? Thanks
EDITED: mesima table is comprised of: ID (AI) text varchar 25 and bool tinyint 1
Upvotes: 0
Views: 1300
Reputation: 14550
You are trying to connect with a port, use this:
Change,
$dsn = 'mysql:host=localhost:1842;dbname=mesimot;charset=utf8';
To
$dsn = 'mysql:host=localhost;dbname=mesimot;port=1842;charset=utf8';
Notice how I defined the port and how you defined the port?
Additional Information
If the queries first value parameter is an auto incrementing ID, then you can leave it blank.
Edit 1
Change,
INSERT INTO mesima VALUES ('', 'first task','0')
To,
INSERT INTO `mesima` (`mesi`, `done_bool`) VALUES ('first task', '0')
Upvotes: 1