mysql error and resource ID:

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



First time setting something like this up. So probably
making some major mistakes.
Anyway I get this message : "mysql_error(Resource id
#2)"

I know it's pointing me to something but not sure what
.

My suspicion since I'm driving blind :) is that I'm
attempting an insert using invalid or incorrectly
stated variables.

Code:

function begin()
{
@mysql_query("BEGIN");
}
function commit()
{
@mysql_query("COMMIT");
}
function rollback()
{
@mysql_query("ROLLBACK", $link);
}
@mysql_connect("myserver","myusername", "mypassword")
or die(mysql_error());

@mysql_select_db("mydatabase") or die(mysql_error());
$link = mysql_connect("myserver", "myusername",
"mypassword");

$query = "INSERT INTO MyTable (RecordID,UserID,Field3,
Field4, ........., )
values 
// these are all the session variables that I'm trying
// to use to insert value , is that wrong

(null,null,$f1a,$f2a,$f2c,$f2d,$f2e,$f2g,$f5b,$f3m,$f3n,$f3e,$f3f,$f3g,$f3h,$f3i,$f3j,
$f3k,$f3l)";
begin(); // transaction begins
$result = @mysql_query($query, $link);

if(!$result)
{
rollback(); // transaction rolls back
echo "you rolled back";
echo " . mysql_error($link)";
exit;
}
else
{
commit(); // transaction is committed
echo "your insertion was successful";
}
?>

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux