Hi Nils,
In you second script can you run it with the following line after your $query;
echo $query;
And post result.
AJ
On 5/31/05, Nils Olofsson <lists at olofsson.tv> wrote:
> On Tue, 2005-05-31 at 13:17 +0100, Kae Verens wrote:
> > Nils Olofsson wrote:
> >
> > >I using this php snipit to return a table entry that matches 10
> > >$query="SELECT title,news from news_post where id=10";
> > >$result=standard myslq connect stuff here.
> > >then I have
> > >while($row=mysql_fetch_array($result){
> > >standard php stuff here
> > >}
> > >
> > >The id is an INT,but what i'm getting back is every record that is in the mysql table.
> > >running the query on the mysql console return only one entry so it can't be mysql.
> > >It seems that if i use differnet variables query1,query2 and so on each
> > >page then it works and returns only what i ask for,I have even used
> > >mysql_free_result($result);
> > >mysql_close($link);
> > >at the end of each page to make sure that the database connection is
> > >closed,i've even put at the start of each page query=0; and query="";
> > >Global variables are turned off in the config so is there anything else
> > >i should be looking at?
> > >
> > >
> >
> > sounds like there's a typo somewhere. can you past the actual source
> > (minus sensetive bits) ?
> >
> > Kae
> >
> Here what i have...
> It only very rough and slapped together + very basic.
> page 1:
> <? php
> $query="SELECT title,lead FROM news_posts ORDER BY id DESC";
> $result=mysql_query($query) or die (mysql_error());
> while($row = mysql_fetch_array($result))
> {
> <a href="shownews.php?id=<? echo $row['title'];?>"/> <? echo
> $row['lead']; ?> </a>
> }
> ?>
>> page two called shownews.php
>> <? php
> $id1=$HTTP_GET_VARS['id'];//global vars are turned off.
> //query
> $query="SELECT * FROM news_posts WHERE id=$id1";
> $result=mysql_query($query) or die (mysql_error());
>> while($row = mysql_fetch_array($result)){
> echo $row['title'];
> echo $row['news'];
> }
>> I took out the html formating as its not important.
> There are about 5 records in the table but what happens is that
> it goes through the while loop spitting out everything
> as if i saild "select * FROM news_posts"
> if i change to variables to query1,result1 in page two it only show
> what i asked for.
>> nils
>>> --
> Irish Linux Users' Group
>http://www.linux.ie/mailman/listinfo/ilug/>>
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!