RE: [PHP-DB] mysql error and resource ID:
| From: | Stuart Felenstein | Date: | Thu, 14 Oct 2004 14:43:07 +0000 |
| Subject: | RE: [PHP-DB] mysql error and resource ID: | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-36802@lists.php.net to get a copy of this message | ||
Quote as in "string" or quote as in 'string' ?
Those two confuse me.
Stuart
--- dpgirago@mdanderson.org wrote:
> If any of the variables used to insert data are
> strings ($f1a, $f2a,
> etc...), you'll need to have quotes around them.
>
> dave
>
>
>
>
>
>
> Stuart Felenstein <stuart4m@yahoo.com>
>
> 10/14/2004 08:26 AM
>
>
>
>
>
> To:
> Graham Cossey <graham@cossey.plus.com>,
> php-db@lists.php.net
> cc:
>
>
>
>
>
> Subject:
> RE: [PHP-DB] mysql error and resource ID:
>
>
>
> Not much luck here on placing the
> mysql_error($link);
> I know the server and database is reachable. So I
> imagine the error is happening in the query. I've
> moved the $link around with no luck.
>
> Stuart
>
> Revised code below:
> --- Graham Cossey <graham@cossey.plus.com> wrote:
>
> <?php
>
> function begin()
> {
> mysql_query("BEGIN");
> }
> function commit()
> {
> mysql_query("COMMIT");
> }
> function rollback()
> {
> mysql_query("ROLLBACK");
> }
> mysql_connect("myserver","myusername", "mypassword")
> or die(mysql_error());
>
> mysql_select_db("mydatabase") or die(mysql_error());
>
> $query = "INSERT INTO MainTable
> (RecordID,UserID,.........)
> values
>
(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 ".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
>
>
>
>