Reply to Re: can't get variable into the query

Your name:

Reply:


Posted by cashmere on 06/18/06 06:47

cashmere@t-online.de wrote:
> cashmere@t-online.de wrote:
> > Geoff Berrow wrote:
> > > Message-ID: <1150560684.019895.139910@i40g2000cwc.googlegroups.com> from
> > > cashmere@t-online.de contained the following:
> > >
> > > >Thanks Geoff - I'm gettting a parse error but looking to see if it's
> > > >maybe a typo.
> > >
> > > This may fix it
> > >
> > > if(mysql_query("INSERT INTO `multiple` VALUES
> > > ('$_POST[id]','$_POST[joketext]')")){
> > > --
> > > Geoff Berrow 0110001001101100010000000110
> > > 001101101011011001000110111101100111001011
> > > 100110001101101111001011100111010101101011
> >
> > Thanks Geoff - that got rid of the parse error - I was trying out
> > different brackets there too.
> > Now it looks ok, but this time the text doesn't make it into the
> > content field, even though the "Joke added" text is displayed.
> > I'm now going to go back through some of my previous attempts using
> > your above syntax.
> > Well, I say now, but the footie starts in 2 mins! (Italy v USA).
> > Cheers Dave
>
> Sorry mens libertina, I didn't see your post till now.
> I'm going to try re-phrasing my problem and will be back shortly.
> Thanks you guys it's really appreciated.
> Cheers Dave

OK here we go:
I get one or more results from a database, that contains people's IDs
and names. I have made the returned entries clickable so the user can
pick the one they're interested in, if more than one entries were
returned.
I found through trial and error that these 2 variations both pass the
clicked member's id to the url of the msg_form page

<a href=msg_form.php?id=$memb_id'>$memb_id</a></td> // or

<a href='msg_form.php?id={$r[0]}'>$r[0]</a></td>
and it was easy to get that value into the INSERT statement.

What my original intention was (and of course still is) is for the user
to enter text via a text field, that will be entered using an UPDATE
query into the new table (called multiple) which (so far) consists of 2
columns, 'id' INT(5) not NULL not auto-increment, and 'content'
TEXT(100).
Of course this

$id=$_GET['id'];
mysql_query("INSERT into `multiple` VALUES ('$id','')");

from my above-posted script runs as soon as the url is clicked. It
creates a row with the id from the url, and the content field empty.
When I try to fill the content field with the text from the form,I find
that the UPDATE instead creates a new row with an id of zero, and the
text correctly in the content field, while the previously inserted row
with the 5 digit id remains unaltered.
So obviously the value of $id is gone at that point!
I then tried to create a session id with that value and pass that to
the UPDATE query, as well as some other stuff, none of which I could
get to work.
So that's where I'm at at this point. Learned a couple of things in the
process though.
When you think about it, it should be easy!
Cheers Dave

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация