Good day,
I'm running a blog page, that's PHP
. I was using PDO
for the connection string, and things worked perfectly.
I have now, recently uploaded to my server, and now I had to change to using mysqli
.
I am new to using this format, as I have always used PDO
.
My coding is below, could someone please assist?
<?php
if (isset($_POST['cmdPost']))
{
try
{
$name = $_POST['txtname'];
$subj = $_POST['txtsubject'];
$msg = $_POST['txtmessage'];
if(empty($name) || empty($subj) || empty($msg))
throw new Exception("Error - Please fill in input fields!");
$stmt = $dbh->prepare("INSERT INTO blogs VALUES (name, subject, message)");
$stmt->bind_param($name, $subj, $msg);
This is where I'm getting the error:
"Fatal error: Call to a member function bind_param() on a non-object in /home/m4230930/public_html/blog.php on line 24"
I have been stuck on this for 3 solid days, I am unsure how to continue.
Could someone please help? Thanks