Results 1 to 7 of 7
  1. #1
    Join Date
    Jan 2005
    Location
    UK, London
    Posts
    762

    php function error (error: Unknown Modifier) help to resolve it plz

    hey everyone,

    I've been recently working on a registeration script, written in php. Im finished and currently de-bugging the script.

    on registeration form, user has the option to enter their website. so in my register.php file, i've made a function that chnages the wronly written web url into correct form. e.g, htp:/ to http://. Anyway, when the script is in use, i keep getting this error:

    Warning: preg_match() [function.preg-match]: Unknown modifier '(' in root\htdocs\members\register.php on line 52
    the error is caused by these lines of code in my register.php file

    PHP Code:
        if ($_POST['website'] != '' & !preg_match("/^(http|ftp):///"$_POST['website'])) {
            
    $_POST['website'] = 'http://'.$_POST['website']; 
    Could anyone please help me debug this code?

    Many thanks in advance for any help anyone can offer

  2. #2
    Join Date
    Jan 2005
    Location
    UK, London
    Posts
    762
    anyone plz?

  3. #3
    Join Date
    Dec 2004
    Location
    Spain
    Posts
    126
    Taking a stab in the dark - have you tried enclosing the http|ftp in square brackets ?

  4. #4
    Change the line to this, and see if it works

    PHP Code:
    if ($_POST['website'] != '' && !preg_match("/^(http|ftp):\\/\\//"$_POST['website'])) { 

  5. #5

    Re: php function error (error: Unknown Modifier) help to resolve it plz

    Originally posted by latheesan
    hey everyone,

    I've been recently working on a registeration script, written in php. Im finished and currently de-bugging the script.

    on registeration form, user has the option to enter their website. so in my register.php file, i've made a function that chnages the wronly written web url into correct form. e.g, htp:/ to http://. Anyway, when the script is in use, i keep getting this error:



    the error is caused by these lines of code in my register.php file

    PHP Code:
        if ($_POST['website'] != '' & !preg_match("/^(http|ftp):///"$_POST['website'])) {
            
    $_POST['website'] = 'http://'.$_POST['website']; 
    Could anyone please help me debug this code?

    Many thanks in advance for any help anyone can offer
    Easy. You're not escaping the forward slashes.

    PHP Code:

    <?php
       $website 
    $_GET['website'];
       
       if(
    $website)
       {
          if(!
    preg_match("/^(http|ftp):\/\//"$website))      
          {
             
    $website "http://".$website;
          }
          
          echo 
    $website."<br>";
       }
    ?>
    Okay the backslashes aren't showing up, it should be:

    / ^ (http|ftp): \ / \ / /

    without the spaces of course
    Small Business Web Hosting with DOT45
    24/7/365 Technical Support; Windows Shared Environment; ColdFusion MX, ASP.NET, PHP, MS SQL, MySQL, Online Store Software, SiteBuilder, Secure Webmail via IlohaMail

  6. #6
    Yeah aixagent, same happened here, doubling the backslashes makes it display ok.

  7. #7
    Join Date
    Jan 2005
    Location
    UK, London
    Posts
    762
    i salute you guys. Thanks for all your help.



    / ^ (http|ftp): \ / \ / / <<<<<<<<< this worked great

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •