Hi folks,
I am a happy little camper, I have recently set up a new website, I have done a content management system, when I put my articles into the database using a form, my homepage displays the five most recent posts in nice preview boxes and links go to www.mysite.com/thesectionname/the-title-split-with-dashes.
On the action page of my CMS form, after I have ran the INSERT query I create a php file using fopen and fwrite, after assigning the whole html page with the form variables in the correct place to one variable using .= the whole way down the page.
I name the file by spltting the title and inserting hyphens using a while loop like so:
$splitname = split(" ",$title);
$counttitle = count($splitname);
$f = 0; while ($f < $counttitle) { $filename .= $splitname[$f]; $filename .= "-"; $f++;};
$smalltitle = strtolower($filename);
$fintitle = substr($smalltitle,0,-1);
I use the same code to create the link on my homepage preview box and it was all working great. Until I used the title Facebook Fall: Beginning of the End?
My file didn't create, error messages, but it had been inserted into the DB, and the link on my front page preview box now went to facebook-fall:-beginning-of-the-end?.php
what a nightmare.
Is there anyway I can check if any of my elements in the split arrays are not letters and act accordingly?