Re: Any One See where this is going wrong?
| From: | Gary | Date: | Sun, 02 May 2010 15:39:54 +0000 |
| Subject: | Re: Any One See where this is going wrong? | ||
| References: | 1 2 3 4 5 6 7 8 9 10 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-304845@lists.php.net to get a copy of this message | ||
"Adam Richardson" <simpleshot@gmail.com> wrote in message
news:AANLkTikUQEhNrjCannzQ8EzvMX5PneG_BJvezgLJ0dKR@mail.gmail.com...
> On Sat, May 1, 2010 at 6:54 PM, Gary <gwpaul@ptd.net> wrote:
>
>>
>> "Adam Richardson" <simpleshot@gmail.com> wrote in message
>>
>> news:AANLkTinqiXXB9oiPU4Op2xzTrZe_vwpbyMAYWziwbhr-@mail.gmail.com...
>> > >
>> >> $sqlStatements = "INSERT INTO guns (manufacturer, type, model,
>> >> caliber,
>> >>
>> > condition, price, description, image_file_name, available) VALUES
>> >
>> > ('$manufacturer',
>> >> '$type',
>> >>
>>
>> '$model','$caliber','$condition','$price','$description','$image_file_name','$available');
>> >
>> > INSERT INTO images(id, image_file) VALUES ('',
>> > '$image_file')";
>> >
>> >
>> > Gary, the second insert has what appears to be a troublesome bit of
>> > code:
>> >
>> > VALUES ('', '$image_file')";
>> >
>> > Shouldn't it read:
>> >
>> > INSERT INTO images(image_file) VALUES ('$image_file')";
>> >
>> > That's assuming you have id set to auto-increment, so no id in the
>> > first
>> > or
>> > second set of parentheses. Additionally, the ", before the $image_file
>> > var
>> > would cause issues, too.
>> >
>> > Adam
>> > --
>> > Nephtali: PHP web framework that functions beautifully
>> > http://nephtaliproject.com
>> >
>> >
>> >
>> > __________ Information from ESET Smart Security, version of virus
>> > signature database 5078 (20100501) __________
>> >
>> > The message was checked by ESET Smart Security.
>> >
>> > http://www.eset.com
>> >
>> >
>>
>> Adam
>>
>> The second INSERT is part of a multi_query, and yes there is a
>> auto-increment field in front named id, it is the foreign key that links
>> the tables.
>>
>> I had removed, and just tried again, but the same result.
>>
>> I have tried it so many ways my fingers and eyes are about to bleed. It
>> makes not sense how it works in one but not the other.
>>
>> I cant see to get the error called out.
>>
>> Thanks again.
>>
>> Gary
>>
>>
>>
>>
>> __________ Information from ESET Smart Security, version of virus
>> signature
>> database 5078 (20100501) __________
>>
>> The message was checked by ESET Smart Security.
>>
>> http://www.eset.com
>>
>>
>>
>>
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
> And you also removed the double quote and the comma next to it (sorry,
> just
> making sure?) That is to say, you copied the line of code I sent?
>
> $sqlStatements = "INSERT INTO guns( *id,*manufacturer, type, model, //
> *id,*should be removed
> caliber, condition, price, description, image_file_name,submitted
> ,available) VALUES ('*',*'$manufacturer', '$type',
> '$model', '$caliber',
> // the *",* combo should be removed
> '$condition', '$price',
> '$description','$image_file_name', ' ',
> '$available');
>
> INSERT INTO images (*id,* image_file) VALUES('','$image_file')";
> //
> the *id,* should be removed AND the *",* combo should be removed
>
> Also, have you tried directly echoing out the error (e.g., *echo
> mysql_error();* if it's mysql you're using, or the comparable method in
> the
> library you're using.)
>
> If that didn't work, I'd break up the multi-query into 2 separate queries
> to
> better troubleshoot the issue. I like using PDO and setting it up so it
> throws exceptions when something goes wrong (additionally, I like using
> the
> prepared statements, too.) Have you been trying that?
>
> I'm still hopeful you'll get this figured out before there's any
> blood-loss
> ;)
>
> Feel free to send back the new code after the edits if you still have
> issues.
>
> Adam
>
> --
> Nephtali: PHP web framework that functions beautifully
> http://nephtaliproject.com
>
>
>
> __________ Information from ESET Smart Security, version of virus
> signature database 5078 (20100501) __________
>
> The message was checked by ESET Smart Security.
>
> http://www.eset.com
>
>
Adam
What I ended up doing was I rebuilt the entire thing from start. I created
one table with one column, made sure it worked, then added a few more, then
added the child table.
The only thing that I can think of is that I had one of the columns named
"id", and maybe that is not allowed.
I also just had the form processed on itself, but I cant really imagine that
would have anything to do with it.
I'll post the code later if interested, I am still adding columns, but the
child is working so that would seem to be the only real challenge.
Thanks for all your input.
Gary
__________ Information from ESET Smart Security, version of virus signature database 5080 (20100502)
__________
The message was checked by ESET Smart Security.
http://www.eset.com