I am trying to bind params to a INSERT INTO MySQLi prepared statement if that variable exists, otherwise insert null.
This is what I have, but it is not working:
if (!empty($name)) {
$result->bind_param('ss', $name, $url_friendly_name);
} else {
$result->bind_param('ss', null, null);
}
if (!empty($description)) {
$result->bind_param('s', $description);
} else {
$result->bind_param('s', null);
}
Does anyone know of a better way of doing this or is there just a minor issue with my code. I am doing the above for each variable in the prepared statement.