Can you help me with a MySQLi problem, or am I on the wrong forum?
I can't find an explanation of the word new in the following code:
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
Regards Awestruck
It's for creating objects: [man]new[/man]
Thanks for the very prompts reply.
Do I have to use the "new" word every time I access the same database in say the data entry file and sort file. In other words can I put: $mysqli = new mysqli("localhost", "my_user", "my_password", "world"); into an include file called say dblink.php Sorry to be so dim, its my first foray into the mysterious world of MySQL. Regards Awestruck
First thing: Props to you for using a recommended API for your first foray into MySQL.
Second: Yes you can put it into an included file, so long as its included BEFORE you make any attempts to use it.Example:
// Good include 'dblink.php'; $mysqli->query('SELECT 1'); // Bad $mysqli->query('SELECT 1'); include 'dblink.php';
HTH
Many thanks
that clarifies the use of "new" and shows me how to include it.