I'm making a interface where the client can create a gallery name, then once submitted, it will add the name to the DB and then create a folder on the server.

Problem is when they use an apostrophe in their name, I try to replace it with a hypen, now when I look on the DB, it's fine, but on the server, it creates a slash and then a hypen, so every folder looks like this: foldername-more

How can I actually remove the apostrophe all together? I actually want to make it so when there is an apostrophe, it gets removed, so a folders called Max's would just become maxs.

Here is my code so far to create the directory and place the file name in the DB:

            $category = strtolower($category); // covert to lowercase
            $category = str_replace(" ","_","$category");  // Replace empty spaces with underscores in string

        $category = str_replace("'","-","$category");  // Replace ' character in string
        chdir("/home/public_html/test");
        mkdir($category,0777);

        $category = addslashes($category); // add slashes to databse
        $db = "test";
        $link = mysql_connect( "localhost", "*****", "*****" );
        if ( !$link ) die( "Couldn't connect to MySQL".mysql_error() );
        mysql_select_db( $db, $link ) or die( "Couldn't open $db: ".mysql_error() );
        $sql = "INSERT INTO test_cat VALUES ('$catid','$category')";
        mysql_query( $sql, $link );
        mysql_close( $link );

and here is my HTML code:

echo"<form action=\"".$PHP_SELF."\" method=\"post\" name=\"form1\">\n"
."        <table align=\"center\">\n"
."          <tr>\n"
."            <td colspan=2 class=\"smalltext\">Create a new category:</td>\n"
."            </tr>\n"
."          <tr>\n"
."            <td colspan=2 class=\"smalltext\"><INPUT TYPE=\"hidden\" Name=\"catid\" VALUE=\"NULL\"></td>\n"
."            </tr>\n"
."            <tr>\n"
."            <td width=\"100\" valign=top class=\"smalltext\">Title:</td>\n"
."                <td><input type=\"text\" name=\"category\" size=30 maxlength=30></td>\n"
."            </tr>\n"
."            <tr>\n"
."                <td align=\"center\" colspan=\"2\">\n"
."                <input class=\"text\" type=\"submit\" value=\"Submit\">\n"
."                </td>\n"
."            </tr>\n"
."        </table>\n"
."        </form>\n";

    add a foward slash in front of the the single quote like i have here

    $category = str_replace("\'","-","$category"); //This escapes this singe quote in the match

      Write a Reply...