Can't run a query inside a function
Posted: Sun Jun 27, 2010 9:20 pm
I've got a MySQL query that runs fine when I put it directly into the code, but won't run when I put it in a function and call the function.
This works nicely. The following does not:
I keep getting the "sql1 didn't work" message.
I've done this (run queries from within a function) lots of times before without problems. The queries also work fine directly in MySQL. What could possibly be going wrong for me that I haven't thought of?
Thanks.
Code: Select all
$sql1 = "Insert into tblPublicSignings (ID,SigningTransID, campaignNo, SignerName, SignerPhone, SignerEmail, Date) Values (NULL,'".$SigningTransID."','".$campaignNo."','".$SignerName."','".$SignerPhone."','".$SignerEmail."','". $Date."')";
$res1 = mysqli_query($mysqli, $sql1) or die("sql1 didn't work");Code: Select all
function testStuff($campaignNo,$SignerName, $SignerPhone, $Date,$SignerEmail,$SigningTransID)
{
$sql1 = "Insert into tblPublicSignings (ID,SigningTransID, campaignNo, SignerName, SignerPhone, SignerEmail,Date) Values (NULL,'".$SigningTransID."','".$campaignNo."','".$SignerName."','".$SignerPhone."','".$SignerEmail."','". $Date."')";
$res1 = mysqli_query($mysqli, $sql1) or die("sql1 didn't work");
}
testStuff($campaignNo,$SignerName, $SignerPhone, $Date,$SignerEmail,$SigningTransID);
I keep getting the "sql1 didn't work" message.
I've done this (run queries from within a function) lots of times before without problems. The queries also work fine directly in MySQL. What could possibly be going wrong for me that I haven't thought of?
Thanks.