Re: mysql error and resource ID:

From: Date: Thu, 14 Oct 2004 12:49:11 +0000
Subject: Re: mysql error and resource ID:
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-36798@lists.php.net to get a copy of this message
A snippet of the source code would help. E "Stuart Felenstein" <stuart4m@yahoo.com> wrote in message news:20041014123112.19470.qmail@web13527.mail.yahoo.com... > 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"; > } > ?>

« previous php.db (#36798) next »