Jump to content


This topic is now archived and is closed to further replies.


Row problem

Recommended Posts

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?


Share this post

Link to post
Share on other sites
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:

[code]$newsart = $_GET['newsart'];[/code]

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.

Share this post

Link to post
Share on other sites
[!--quoteo(post=362431:date=Apr 6 2006, 10:25 PM:name=script)--][div class=\'quotetop\']QUOTE(script @ Apr 6 2006, 10:25 PM) [snapback]362431[/snapback][/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 /

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.