[nycphp-talk] Bizarro Bug trying to insert after using mysql_insert_row
Kristina Anderson
ka at kacomputerconsulting.com
Wed Apr 2 11:18:10 EDT 2008
114 jkljlk tyuti ttyut tyutu 0 NULL 0 [0 NULL ]
113 jkljlk tyuti ttyut tyutu 0 NULL 0 0 NULL
Last two fields in row 114 s/b "113"....but.
Query as follows looks OK to me...
INSERT INTO who_we_are SET eid=113,eid2='113', empname ='jkljlk',
title='tyuti', bodytext='ttyut tyutu', picture=''
> 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
> _______________________________________________
> New York PHP Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> NYPHPCon 2006 Presentations Online
> http://www.nyphpcon.com
>
> Show Your Participation in New York PHP
> http://www.nyphp.org/show_participation.php
>
>
More information about the talk
mailing list