By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,805 Members | 1,273 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,805 IT Pros & Developers. It's quick & easy.

Prepared Statment seems to run but doesn't affect database

P: n/a
I have written a function that runs a prepared statement and it seems
to run just fine but when I check to see the affected rows nothing is
affected. Can someone take a look at my code and tell me if they notice
anything wrong outright.

[CODE BLOCK for config.php]
function QueryDB_mysqli($query, $typeStr, $varStr){
$db_connection = new mysqli(DB_HOST, DB_USER, DB_PASSWORD,DB_DATABASE);
$statement = $db_connection->prepare($query);
$statement->bind_param($typeStr, $varStr);
$statement->execute();
$statement->close();
exit();
}

[END CODE BLOCK]

[CODE BLOCK for mgb.php]
$varStr = $userID . "," . $end_book . "," . $start_book . "," . $title
.. "," . $notes . "," . $start_date . "," . $end_date . "," . $skip_days
.. "," . $email_reminder . "," . date("Ymd",time()) . "," . $today;

$typeStr = "sssssssssss";

QueryDB_mysqli("INSERT INTO
schedule
SET
userID=?,
end_book =?,
start_book=?,
title=?,
footnotes=?,
start_date=?,
end_date=?,
skip_days=?,
email_reminder=?,
last_accessed=?,
creation_date =?", $typeStr, $varStr);
[END CODE BLOCK]

I can't understand why it wouldn't throw an error yet insert nothing
into the database. Any help would be greatly appreciated.

Thanks in advance,
Joe

Jul 13 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On 13 Jul 2006 08:38:15 -0700, to*********@gmail.com wrote:
>I have written a function that runs a prepared statement and it seems
to run just fine but when I check to see the affected rows nothing is
affected. Can someone take a look at my code and tell me if they notice
anything wrong outright.

[CODE BLOCK for config.php]
function QueryDB_mysqli($query, $typeStr, $varStr){
$db_connection = new mysqli(DB_HOST, DB_USER, DB_PASSWORD,DB_DATABASE);
$statement = $db_connection->prepare($query);
$statement->bind_param($typeStr, $varStr);
$statement->execute();
$statement->close();
exit();
}
Is autocommit on or off? If off, it's probably doing a rollback at end of
script.

--
Andy Hassall :: an**@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Jul 13 '06 #2

P: n/a
Andy,

Thanks for your reply. Autocommit is turned on. I'm not too
familiar with that function or what you mean by a rollback, but since
it is on I am not sure what to do.
Andy Hassall wrote:
On 13 Jul 2006 08:38:15 -0700, to*********@gmail.com wrote:
I have written a function that runs a prepared statement and it seems
to run just fine but when I check to see the affected rows nothing is
affected. Can someone take a look at my code and tell me if they notice
anything wrong outright.

[CODE BLOCK for config.php]
function QueryDB_mysqli($query, $typeStr, $varStr){
$db_connection = new mysqli(DB_HOST, DB_USER, DB_PASSWORD,DB_DATABASE);
$statement = $db_connection->prepare($query);
$statement->bind_param($typeStr, $varStr);
$statement->execute();
$statement->close();
exit();
}

Is autocommit on or off? If off, it's probably doing a rollback at end of
script.

--
Andy Hassall :: an**@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Jul 13 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.