RE: [PHP-DB] mysql error and resource ID:
| From: | Graham Cossey | Date: | Thu, 14 Oct 2004 12:54:04 +0000 |
| Subject: | RE: [PHP-DB] mysql error and resource ID: | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-36796@lists.php.net to get a copy of this message | ||
A few ideas...
[snip]
> Anyway I get this message : "mysql_error(Resource id
> #2)"
>
[snip]
> @mysql_connect("myserver","myusername", "mypassword")
> or die(mysql_error());
>
> @mysql_select_db("mydatabase") or die(mysql_error());
> $link = mysql_connect("myserver", "myusername",
> "mypassword");
Second mysql_connect(), why?
Also, no mysql_select_db for this db connection.
Try removing the @s until it's all working.
[snip]
> begin(); // transaction begins
> $result = @mysql_query($query, $link);
You are now using $link that has not had a mysql_select_db()
>
> if(!$result)
> {
> rollback(); // transaction rolls back
> echo "you rolled back";
> echo " . mysql_error($link)";
echo "You rolled back ".mysql_error($link);
And place this before rollback() or else the mysql statement in rollback()
will probably reset the error.
HTH
Graham