script Posted April 7, 2006 Share Posted April 7, 2006 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 sofor new arcticle 54 the link would be .../newsarticle.php/54the 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 thislist($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 $newsartunfortunately 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?-script Quote Link to comment Share on other sites More sharing options...
freakus_maximus Posted April 7, 2006 Share Posted April 7, 2006 If you are storing the actual article in the database (which I am assuming) why not try setting your links to ../newsarticle.php?newsart=54Then 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. Quote Link to comment Share on other sites More sharing options...
Rahnetjera Posted April 7, 2006 Share Posted April 7, 2006 [!--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--] .../newsarticle.php/54list($newsart) = explode('/', substr($PATH_INFO,1));[/quote]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 stringsProgram FIles php and newsarticle.php and finally the 54substr() is dropping the last byte of $PATH_INFO which is possibly your trailing / 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.