[nycphp-talk] Bizarro Bug trying to insert after using mysql_insert_row
Daniel Convissor
danielc at analysisandsolutions.com
Wed Apr 2 11:07:54 EDT 2008
Hi Kristina:
On Tue, Apr 01, 2008 at 07:57:48PM -0700, Kristina Anderson wrote:
> I'm pulling out the ID of the previously inserted row and then
> inserting that as a lookup value in a duplicate row (two rows one for
> edit mode one for published mode).
>
> Various other places in the app this works fine and there really isn't
> any reason this should be happening.
>
> The query runs fine if I do it from within phpMyAdmin -- but from the
> PHP page the query does not error out but the value in the lookup field
> remains the default value
You say you're using "mysql_insert_row." I assume you mean PHP's
mysql_insert_id() function. If so, there are two possible bugs that come
to mind.
1) The table in question does not have auto_increment set for the primary
key on that table. If that's not it...
2) The PHP code has a bug...
You say this same logic works on other parts of the site. So, do the
various parts of the site use the _same_ _exact_ files/lines/functions or
do you have separate function/include/whatever for each section of the
application?
If you're using separate code for different sections, obviously the PHP
code you're using for the problematic insert is where the bug is.
Perhaps the variable you assign the id to is different than the variable
you're using as the lookup value in the second query.
Again, if you're using separate code, you should refactor the system to
allow you to use the same code for the same purpose throughout the
system.
--Dan
--
T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y
data intensive web and database programming
http://www.AnalysisAndSolutions.com/
4015 7th Ave #4, Brooklyn NY 11232 v: 718-854-0335 f: 718-854-0409
More information about the talk
mailing list