I have a simple MySQL query designed to get a single value from a MySQL database:
$cr = 'copyright';
$stmt = $con->prepare("SELECT ${_COOKIE['lang']} FROM lang WHERE page = ?");
$stmt->bind_param("s", $cr);
$stmt->execute();
$stmt->bind_result($result);
$stmt->fetch();
$copyright = $result;
I have another simple MySQL query to get a different single value from the same table in the same database:
$cb = 'contactblurb';
$stmt = $con->prepare("SELECT ${_COOKIE['lang']} FROM lang WHERE page = ?");
$stmt->bind_param("s", $cb);
$stmt->execute();
$stmt->bind_result($result);
$stmt->fetch();
$blurb = $result;
They both work independently of each other and retrieve the required data. However, when placed one after another, like so...
$cr = 'copyright';
$stmt = $con->prepare("SELECT ${_COOKIE['lang']} FROM lang WHERE page = ?");
$stmt->bind_param("s", $cr);
$stmt->execute();
$stmt->bind_result($result);
$stmt->fetch();
$copyright = $result;
$cb = 'contactblurb';
$stmt = $con->prepare("SELECT ${_COOKIE['lang']} FROM lang WHERE page = ?");
$stmt->bind_param("s", $cb);
$stmt->execute();
$stmt->bind_result($result);
$stmt->fetch();
$blurb = $result;
I get the following error for the third line of the second query.
Uncaught Error: Call to a member function bind_param() on bool...
What am I missing? I'm not closing any connections between the two queries? Is there something I'm missing?
The statements have to be called separately as one is calling data that will be used site-wide and the other is for a specific page only.