Just finished installing MySQL on my Macbook in order to do my web dev homework assignment. I'm running my web pages using the mac webserver at Macintosh HD/Library/WebServer/Documents/. When I try to execute my php file from the terminal with the following code to create a table in a database I get the error also below.
Code Executed from the terminal using "php fileName.php":
<?php
$mysqli = new mysqli(localhost, root, ****, lab7);
$query = "CREATE TABLE products (ID int primary key)";
$mysqli->query($query);
$mysqli->close();
?>
Error:
Warning: mysqli::__construct(): (HY000/2002): No such file or directory in /Library/WebServer/Documents/week7/Lab7/CreateTableTest.php on line 2
Warning: mysqli::query(): Couldn't fetch mysqli in /Library/WebServer/Documents/week7/Lab7/CreateTableTest.php on line 6
Warning: mysqli::close(): Couldn't fetch mysqli in /Library/WebServer/Documents/week7/Lab7/CreateTableTest.php on line 8