Pool tables - Mortgage Calculator - Mortgage Calculator - MPAA - Loans

PDA

View Full Version : php code to turn mysql auto commi off


ianlufc
Apr 28th 2008, 9:42 am
hey guys

i am trying to turn autocommit off and use transactions but
autocommit=0
and
autocomit=false

aint working

im using it on server2go

anyone any ideas

cheers

jestep
Apr 28th 2008, 10:22 am
It should be like this:


$db = new mysqli(.....);
$db->autocommit(FALSE);

//do a bunch of queries...

$db->commit();



If you want to throw error handling in there I use this:



if(!$db->commit()){

die($db->error);

}



I think this may require using innodb storage so make sure you're not using myisam if you're still having problems.

ianlufc
Apr 28th 2008, 10:27 am
do i have to install anything new to use mysqli?????

appreciate this help man

jestep
Apr 28th 2008, 10:45 am
As long as the mysqli extension is enabled in the php build, then there is nothing else that needs to be done.

Check your phpinfo(). There should be: "--with-mysqli=..." in the Configure Command.

ianlufc
Apr 28th 2008, 10:53 am
mysqli
MysqlI Support enabled
Client API library version 5.0.22
Client API header version 5.0.36
MYSQLI_SOCKET /tmp/mysql.sock

Directive Local Value Master Value
mysqli.default_host no value no value
mysqli.default_port 3306 3306
mysqli.default_pw no value no value
mysqli.default_socket no value no value
mysqli.default_user no value no value
mysqli.max_links Unlimited Unlimited
mysqli.reconnect Off Off



thats what i get from phpinfo()

im building a shopping website for my final yr project in colege and had it all finished then i noticed i need a transaction for one part of it...its doing my head in.....cant even get it connected with mysqli........

keep getting
Warning: mysqli::mysqli() [function.mysqli-mysqli]: (HY000/2003): Can't connect to MySQL server on 'localhost' (10061) in C:*******\****\store\connect.php on line 11
Connect failed: Can't connect to MySQL server on 'localhost' (10061)

connect.php
<?php
/*
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("bookstore", $con);
*/
///////
$mysqli = new mysqli("","","","bookstore");
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
?>

old connection is commented out

cheers man