Prepared Statements

Disregarding that the error looks to be not line 5 but line 3 in your code example, the code does have
include 'config.php';

Did you not define the variable as a database resource in that file?

1 Like

It looks like this:

config.php

<?php

/*
ERROR HANDLING
*/
declare(strict_types=1);
ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
error_reporting(E_ALL);

mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);

// session start
if(!session_start()) {
	session_start();
}

// include files
include 'conn.php';
include 'site_details.php';

// include functions
include 'functions.php';

?>

I think the point @ahundiak is trying to make is that it is so obvious that this variable refers to your database connection that you should substitute that name instead, and that if you need that to be explained, then something is wrong after all these posts.

Example please, of a prepared statement in PDO that does not use placeholders?

I donā€™t think Iā€™d agree with that interpretation. The idea of a wrapper is not that you paste your code into an exe and that ā€œconvertsā€ your code and then spits out the completed version. Thatā€™s more of a type of code-completion, or like the code snippets in Visual Studio. To me, a wrapper is a function or a series of functions that you keep in a library and call when you need them, and those functions (like any function, really) do the repetitive things that you donā€™t want to keep typing out.

3 Likes

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.