Another person on another forum suggested the following:
if ($con = new MySQLi('localhost', 'user', 'password', 'db'))
{
$sQry = "INSERT INTO payments (client_id, userid, pmt_date, pmt_amt)
SELECT client_id, user_id, ?, ? FROM clients WHERE client_id = ?";
if ($stmt = $con->prepare($sQry))
{
$stmt->bind_param('sss', $_POST['date'], $_POST['amount'], $_SESSION['client_id']);
$stmt->execute();
$stmt->close();
}
}
I tweaked it for my own purposes and I'm getting an error...suggestions?
if ($con = new MySQLi('localhost', 'root', 'admin', 'webmasterbark'))
{
$sQry = "INSERT INTO payments (client_id, userid, pmt_date, pmt_amt)
SELECT client_id, userid FROM clients WHERE client_id = " . $_SESSION['client_id'];
if ($stmt = $con->prepare($sQry))
{
$stmt->bind_param('sss', $_POST['date'], $_POST['amount'], $_SESSION['client_id']);
$stmt->execute();
$stmt->close();
}
}
And here's the error:
Warning: mysqli_query() [function.mysqli-query]: Empty query in /home/content/w/e/b/webmasterbark/html/csac/login/addpmt.php on line 18
Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 2