Good day community!
I decided to delve into the depths of php and mysql with the book "PHP and MySQL. From beginner to professional." I really like the book almost all worked, when working with a book I use XAMPP, but one nuance bothers me.
I connect to a specific database table using a script:
try { $pdo = new PDO('mysql:host = localhost; dbname = ijdb', 'ijdbuser', 'pass'); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $pdo->exec('SET NAMES "utf8"'); } catch (PDOException $e) { $output = 'Невозможно подключиться к серверу баз данных! ' . $e -> getMessage(); include 'output.html.php'; exit(); } Which implies a connection to a specific server database, and as a result I cannot write a query of the type:
SELECT joke.id, joketext, name, email FROM joke INNER JOIN author on authorid = author.id the server eats the request only if I modify it:
SELECT joke.id, joketext, name, email FROM ijdb .joke INNER JOIN ijdb .author on authorid = author.id
At the first option the error appears:
QLSTATE [3D000]: Invalid catalog name: 1046 No database selected
* How to get rid of redundancy writing!?