Re: [PHP-DB] mysql error and resource ID:
Stuart Felenstein wrote: First time setting something like this up. So probably making some major mistakes. Anyway I get this message : mysql_error(Resource id #2) [snip] echo . mysql_error($link); Read the above line or use an editor that does syntax highlighting. Also, you'll want to get the error before you run the rollback() function. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] mysql error and resource ID:
See PHP manual Chapter 6. Types Strings for an explanation of single double quotes. From the doc: If the string is enclosed in double-quotes (), PHP understands more escape sequences for special characters But the most important feature of double-quoted strings is the fact that variable names will be expanded. In your case it would be ' within . $query = INSERT INTO MainTable (RecordID,UserID,.) values(null,null,'$f1a','$f2a',...); Graham. -Original Message- From: Stuart Felenstein [mailto:[EMAIL PROTECTED] Sent: 14 October 2004 15:43 To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: RE: [PHP-DB] mysql error and resource ID: Quote as in string or quote as in 'string' ? Those two confuse me. Stuart --- [EMAIL PROTECTED] 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 [EMAIL PROTECTED] 10/14/2004 08:26 AM To: Graham Cossey [EMAIL PROTECTED], [EMAIL PROTECTED] 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 [EMAIL PROTECTED] 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 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] mysql error and resource ID:
Anyone see something wrong here : My error message is : 0: 1064: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'd',1,'d',1,1, 31, 33,10/15/2004))' at line 5 Code: $query = INSERT INTO MainTable (RecordID,UserID,other fields..) values (null,null,'$f1a',$f2a,$f2c,$f2d,$f2e,$f2g,'$f5b','$f3m','$f3n,'$f3e',$f3f,'$f3g',$f3h,$f3i, $f3j, $f3k,$f3l)); //not sure if the double ) is //needed though it doesn't make a diff begin(); // transaction begins $result = mysql_query($query); --- Stuart Felenstein [EMAIL PROTECTED] wrote: -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] mysql error and resource ID:
Yes, actually my apologies to everyone. I figured out the error. So , yep, I'm down to a problem with the date. The column is set to date. I'll go ahead and add the quotes. Stuart --- [EMAIL PROTECTED] wrote: Stuart, The date has forward slashes. These are not integers, right? So put single quotes around the whole date, like '10/15/2004'. dave Stuart Felenstein [EMAIL PROTECTED] 10/14/2004 10:02 AM To: Stuart Felenstein [EMAIL PROTECTED] cc: [EMAIL PROTECTED] Subject: RE: [PHP-DB] mysql error and resource ID: Anyone see something wrong here : My error message is : 0: 1064: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'd',1,'d',1,1, 31, 33,10/15/2004))' at line 5 Code: $query = INSERT INTO MainTable (RecordID,UserID,other fields..) values (null,null,'$f1a',$f2a,$f2c,$f2d,$f2e,$f2g,'$f5b','$f3m','$f3n,'$f3e',$f3f,'$f3g',$f3h,$f3i, $f3j, $f3k,$f3l)); //not sure if the double ) is //needed though it doesn't make a diff begin(); // transaction begins $result = mysql_query($query); --- Stuart Felenstein [EMAIL PROTECTED] wrote: -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php