Jump to content

Code producing error message! Please help!


canadian_angel

Recommended Posts

Hi,

I have a problem, everytime I run this this code I get these error messages, and I can't figure out why, I have gone over every line but I must be missing something.

 

 

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

 

 

 

<!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>

 

The error is referring to the string ":alum" in these two line:

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

which should be ":alnum"

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

 

Ken

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.