fonster_mox Posted August 30, 2008 Share Posted August 30, 2008 Hi, I'm very new to php so I don't really know what I am doing. I am recieving the message Notice: Undefined variable: row in /mysite.com/article.php on line 62 I know this is because I haven't defined $row but I don't know what it's supposed to be defined as, or where as I said, very new to php! the page is supposed to get the id from the url, eg article.php?=10 should post only the row of the table with the id 10. <? $id=$row["id"]; $db=mysql_connect("localhost","*****","*****") or die ('cant connect'); mysql_select_db("*****",$db) or die ("cant change"); $news=mysql_query("select * from news WHERE id='$id' ORDER BY id DESC LIMIT 1") or die ("cant get table"); while($rows=mysql_fetch_array($news)){ $body=$rows["body"]; $title=$rows["title"]; $date=$rows["date"]; $author=$rows["author"]; $email=$rows["email"]; $smallcontent=$rows["smallcontent"]; echo "<div class=\"newsitem\"> <div class=\"newstop\"></div> <div class=\"newsmiddle\"> <div class=\"innernews\"> <span class=\"newshead\">$title</span><br /> <span class=\"byline\">By <a href=\"mailto:$email\">$author</a> on $date</span><br /><br /> $body <br /><br /> </div> </div> <div class=\"newsbottom\"></div> </div>"; } ?> would be really grateful with an explanation of what I've done wrong or just the correct way to do it, thanks, fonmo. Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted August 30, 2008 Share Posted August 30, 2008 where is $row defined before this line of code? $id=$row["id"]; Quote Link to comment Share on other sites More sharing options...
fonster_mox Posted August 30, 2008 Author Share Posted August 30, 2008 It isn't, I know but that's my problem, I don't know what I'm supposed to define it as (seriously new to php ) Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted August 30, 2008 Share Posted August 30, 2008 http://www.php.net/manual/en/reserved.variables.get.php Quote Link to comment Share on other sites More sharing options...
fonster_mox Posted August 30, 2008 Author Share Posted August 30, 2008 http://www.php.net/manual/en/reserved.variables.get.php I've tried using this page but I still can't figure it out. I appreciate that you're trying to get me to help myself but I don't even understand most of the code I have so far (a friend helped me through it, who's on holiday now). To fix my own problem using the link you've provided would mean going back a few dozen steps to learn some basics first, which I don't really have time for. But I'm quite sure if someone just showed me what I'm missing (I'm sure it's very easy for someone with experience, it's a very basic news post system linking to a full size article, the site you can find on thousands of sites already), I'm sure I would learn a lot from it. Thanks, anyway Quote Link to comment Share on other sites More sharing options...
fonster_mox Posted August 30, 2008 Author Share Posted August 30, 2008 I take that back (sorry to double post, but modify has gone, I assume it's on a timer). I did figure it out, thank you! It was thanks to being swerved back to that GET code. I had googled previously and thought GET was what I needed, but couldn't get it right. In the end, your insistence and a bit of trial and error proved me wrong. All I needed was $id=$_GET['id']; above $news=mysql_query("select * from news WHERE id='$id' ORDER BY id DESC LIMIT 1") or die ("cant get table"); Thanks again, consider this solved and closable Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.