Page 1 of 1

Code producing error message! Please help!

Posted: Sat Jun 26, 2010 4:17 pm
by canadian_angel
Hi I have a bit of a problem, when I run this script in a browser it comes up with these 2 error messages, and I cant figure out why. I have gone over every line but I must be missing something. But WHAT?

Warning: eregi() [function.eregi]: REG_ECTYPE in C:\AppServ\www\chapter13\convert_url.php on line 26

Warning: eregi() [function.eregi]: REG_ECTYPE in C:\AppServ\www\chapter13\convert_url.php on line 31

Code: Select all

<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-Transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
        <title>Make URL Click-able</title>
    </head>
    <body>
        <?php // Script 13.2 - convert_url.php
        // This script turns a valid URL into an HTML link.

      // Address error handling.
        ini_set ('display_errors', 1);
        error_reporting (E_ALL & ~E_NOTICE);
        
        if ( isset ($_POST['submit'])) { // Has the form been submitted?

            // Trim off extraneous spaces, just in case.
            $url = trim ($_POST['url']);

            // Establish the patterns.
            $pattern1 = '^((http|https|ftp)://){1}([[:alum:]-])+(\.)([[:alum:]-]){2,4}([[:alum:]/+=%&_.~?-]*)$';
            $pattern2 = '^([[:alum:]-])+(\.)([[:alum:]-]){2,4}([[:alum:]/+=%&_.~?-]*)$';

            // Test the submitted value against the patterns.
            if (eregi ($pattern1, $url)) { // Check for an existing http/https/ftp.

                $url = eregi_replace ($pattern1,'<a href="\\0">\\0</a>', $url);
                print "<p>Here is the URL: $url<br />The code is now: " . htmlentities ($url) . '</p>';

            } elseif (eregi ($pattern2, $url)) { // No http/https/ftp, add http://.

                $url = eregi_replace ($pattern2,'<a href="http://\\0">\\0</a>', $url);
                print "<p>Here is the URL: $url<br />The code is now: " . htmlentities ($url) . '</p>';

            } else { // Invalid URL.
                print '<p>Please enter a valid URL.</p>';
            }

        } // End of main conditional.
        // Display the HTML form.
        ?>
        <form action="convert_url.php" method="post">
        <p>URL: <input type="text" name="url" size="30" /></p>
        <input type="submit" name="submit" value="Convert" />
        </form>
    </body>
</html>

Re: Code producing error message! Please help!

Posted: Sat Jun 26, 2010 5:52 pm
by requinix
There is no class name "alum"...

Re: Code producing error message! Please help!

Posted: Sun Jun 27, 2010 10:13 am
by AbraCadaver
Not the problem here, but you should be using preg_replace() as the ereg* functions are deprecated.