Jump to content

Row problem


script

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?

-script
Link to comment
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

../newsarticle.php?newsart=54

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.
Link to comment
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--]
.../newsarticle.php/54

list($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 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 /



Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.