Jon Frisby---MySQL help needed
Hi Jon, Whatever you have suggested so far hasn't worked. I thought that maybe something is missing in my stating the problem and implementing your suggested solutions. So here is a more expanded picture of the queries: $sth=$dbh-prepare(INSERT INTO TABLE1 (id,var1,var2) VALUES (?,?,?)); $sth-execute(,$var1,$var2); $sth=$dbh-prepare(SELECT \@t1id:=LAST_INSERT_ID()); $sth-execute(); $sth=$dbh-prepare(INSERT INTO TABLE1A (Aid,id,var1) VALUES (?, @t1id, $var1); $sth-execute(,,$var1); Please take a note that in the last prepare statement I have also tried \@t1id ,\@t1id, LAST_INSERT_ID(). I have used these in 'execute' statement too with question marks (?) in the prepare statement. Any new idea please? Thanks, Aamer Try: $sth-execute(...); Sorry for the confusion. Of course I tried the above statement. I took it granted that we would mean the above when we say the following: execute(, \@t1id, $var1...); I still get the same result. I hope you don't quit on me. Thanks. Hrm... Ah! If your code is doing a prepare on a statement of the form: INSERT INTO x VALUES(@t1id, ...) Then you don't need to give @t1id as a parameter in the execute statement... You should only need to provide params to execute for each ? that appears in the INSERT statement... -JF sql, query - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
Re: Jon Frisby---MySQL help needed
On Mon, Jul 29, 2002 at 01:13:30PM -0400, Aamer Rauf wrote: Hi Jon, Whatever you have suggested so far hasn't worked. I thought that maybe something is missing in my stating the problem and implementing your suggested solutions. So here is a more expanded picture of the queries: $sth=$dbh-prepare(INSERT INTO TABLE1 (id,var1,var2) VALUES (?,?,?)); $sth-execute(,$var1,$var2); $sth=$dbh-prepare(SELECT \@t1id:=LAST_INSERT_ID()); $sth-execute(); $sth=$dbh-prepare(INSERT INTO TABLE1A (Aid,id,var1) VALUES (?, @t1id, $var1); $sth-execute(,,$var1); Doesn't this chain of events reuse the variable $sth, which essentially closes the old statement handler? Doesn't that lose state? I'm guessing... Please take a note that in the last prepare statement I have also tried \@t1id ,\@t1id, LAST_INSERT_ID(). I have used these in 'execute' statement too with question marks (?) in the prepare statement. Any new idea please? Try grabbing the new ID manually, before the second prepare: my $id = $dbh-{'mysql_insertid'}; Then, manually use that as a bind variable. Thanks, Aamer -- Brian 'you Bastard' Reichert[EMAIL PROTECTED] 37 Crystal Ave. #303Daytime number: (603) 434-6842 Derry NH 03038-1713 USA Intel architecture: the left-hand path - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
RE: Jon Frisby---MySQL help needed
Whatever you have suggested so far hasn't worked. I thought that maybe something is missing in my stating the problem and implementing your suggested solutions. So here is a more expanded picture of the queries: $sth=$dbh-prepare(INSERT INTO TABLE1 (id,var1,var2) VALUES (?,?,?)); $sth-execute(,$var1,$var2); $sth=$dbh-prepare(SELECT \@t1id:=LAST_INSERT_ID()); $sth-execute(); After this, try the following: $sth2 = $dbh-prepare(SELECT \@t1id); $sth2-execute(); $tmp = $sth2-fetchrow_arrayref(); print ID: . $tmp-[0]; See if you're getting a number here or not... $sth=$dbh-prepare(INSERT INTO TABLE1A (Aid,id,var1) VALUES (?, @t1id, $var1); Note that using @t1id in double-quotes without escaping the @ will *never* work, because Perl will think you are trying to use a Perl variable, when in reality @t1id is a MySQL variable. $sth-execute(,,$var1); Why are you sending unused bound parameters? Try this: $sth = $dbh-prepare(INSERT INTO TABLE1A (Aid,id,var1) VALUES (0, \@t1id, $var1); $sth-execute(); -JF - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php