Jump to content


Row problem

  • Please log in to reply
2 replies to this topic

#1 script

  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 07 April 2006 - 03:25 AM

Hey I have a webpage, well this senario deals with two pages really.

One page the first one has the subjects of the lastest three news article that gets pulled from my database, each record has a keyfield named newsfield and simply auto increments by one for each new article.

Ok so I have the subjects on the first page and next to that is a link to another page to read the whole article. This other page is newsarticle.php and is the same for every link you click on, what differes is that the row number or newsfield is added to the end of the link like so

for new arcticle 54 the link would be .../newsarticle.php/54

the second page takes the 54 and inputs it into a variable to use to find the proper article that you want to see. I'm running into the problem with this

list($newsart) = explode('/', substr($PATH_INFO,1));

that's the line of code that parses out whatever is after the / in this case a 54 and put it into $newsart

unfortunately it's not working properly, I've been trying to debug it but all I get is qeury failed everytime I try to run the page. Apparently whatever is in $newsart doesn't exist. Would there be a way to find out what's in the variable before anything else happens?


#2 freakus_maximus

  • Members
  • PipPipPip
  • Advanced Member
  • 177 posts

Posted 07 April 2006 - 12:58 PM

If you are storing the actual article in the database (which I am assuming) why not try setting your links to


Then in the actual newsarticle.php page have get the variable value:

$newsart = $_GET['newsart'];

Obviously your original page that list the links will need to pull in the id of the news article in the db as part of the link.

#3 Rahnetjera

  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 07 April 2006 - 05:07 PM

[!--quoteo(post=362431:date=Apr 6 2006, 10:25 PM:name=script)--][div class=\'quotetop\']QUOTE(script @ Apr 6 2006, 10:25 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]

list($newsart) = explode('/', substr($PATH_INFO,1));

I'm gonna take a stab at this.

$PATH_INFO = "<SOME DIR>/newsarticle.php/"; # WITH TRAILING / ?

using explode() you are splitting Full path at each instance of '/'

Win ex: C:\Program FIles\php\newsarticle.php gives three strings
Program FIles php and newsarticle.php and finally the 54

substr() is dropping the last byte of $PATH_INFO which is possibly your trailing /

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users