I am now done with my comment function, created to grant the visitors the possibility to comment an article. But there is one thing that I cannot solve (Note: It has been three weeks since I first started to use PHP) so therefore I thought that somebody might be so kind to help me with my problem.
It is in my index.php where I have some previews of articles and other stuff, but most importantly in this issue the function to see the latest 3 comments. And in these boxes I have created a link that will direct the visitor to the certain HTTP adress where the commented article is located. Now the pop-up box where you comment an article has a function that will fetch the article ID of the article and create a comment site with the same ID. Here is a typical link to an article: http://www.mysite.co...Site440.dbp.asp
Don't ask why the article's are made in ASP and the comments in PHP Long story
Anyway the link that will link to its mother (the articles HTTP) is created in the way that you can see in Listing 1:
$link = 'http://www.mysite.com/articles/'.substr($article_id, 0, 6).'/'.substr($article_id, 6, 2).'/'.substr($article_id, 0, 22).'/'. $article_id;
So in other words the ID of the article is for an example 20060421151548_Site440.dbp.asp and the function above will make that the link will automatically link to the correct folder/sub-folder etc. But the problem is this: most of the time the article ID does not include "Site" and is therefore only; 20060421151548_440.dbp.asp. But my code will therefore generate the following link: http://www.mysite.co...Site440.dbp.asp which will link to a non-existing site. It should be http://www.mysite.co...548_440.dbp.asp
But how do I manage to do this without f***ing with the links that has Site in them?
Thankful for help.