Jump to content
MakeWebGames

checkem.php error code (SOMEONE HELP)


snaketooth22

Recommended Posts

Im getting an error on this line in the checkem.php ,..

ive fixed the rest so that its compatible with the new versions of the PHP on the servers,.

I just cant figure out what im doing wrong on this line,.. can anyone help please :) ,..

 

 

if (!preg_match("/^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$/", $local_array[$i])) {

 

 

(ERROR CODE): Warning: preg_match() [function.preg-match]: Unknown modifier '=' in /home4/jedigunz/public_html/checkem.php on line 13

Link to comment
Share on other sites

Yet again, the error message makes it obvious: ` Unknown modifier '=' `

You cannot use the primary delimiters, in this case / within the expression itself. Anything after the second one is assumed to be a modifier.. in this case '='

if (!preg_match("/^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$/", $local_array[$i])) {

At a guess I'd say your expression needs simplifying - [!-~]{1,63} perhaps -- just make sure you escape it (mysql_real_escape_string etc) going into the database and escape it (htmlentities etc) going out to the screen.

Link to comment
Share on other sites

speaking to yuh in the IRC yuh now know its an email thing,. Octarine where abouts do yuh mean to put that small peice of code,.. do yuh mean to replace a specific part of the code that already exists ??

I do now, so use what Nick said filter_var()

Link to comment
Share on other sites

http://uk3.php.net/mysql_real_escape_string

If you're checking an E-mail (as Ian said) FILTER_VALIDATE_EMAIL - http://uk3.php.net/filter_var

i cant place what i need to change,.. all it is is one line of code,. which needs a minor edit,. let me show yuh the script and what ive done,..

Everything in bold italics is what ive changed / added ,.. i originally had 5 errors on the register page in the email to be classed as real section ,.. what i done eliminated 4 of the errors

but there is still 1 error remaining on line 13,..

Originally there was ereg instead of preg_match and i added /// in places where i was supposedly meant to according to every website ive googled,.

 

Warning: preg_match() [function.preg-match]: Unknown modifier '=' in /home4/jedigunz/public_html/checkem.php on line 13

 

<?php
//thx to http://www.phpit.net/code/valid-email/ for valid_email
function valid_email($email) {
 // First, we check that there's one @ symbol, and that the lengths are right
 if (!preg_match("/^[^@]{1,64}@[^@]{1,255}$/", $email)) {
   // Email invalid because wrong number of characters in one section, or wrong number of @ symbols.
   return false;
 }
 // Split it into sections to make life easier
 $email_array = explode("@", $email);
 $local_array = explode(".", $email_array[0]);
 for ($i = 0; $i < sizeof($local_array); $i++) {
   if (!preg_match("/^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$/", $local_array[$i])) {
     return false;
   }
 }  
 if (!preg_match("/^\[?[0-9\.]+\]?$/", $email_array[1])) { // Check if domain is IP. If not, it should be valid domain name
   $domain_array = explode(".", $email_array[1]);
   if (sizeof($domain_array) < 2) {
       return false; // Not enough parts to domain
   }
   for ($i = 0; $i < sizeof($domain_array); $i++) {
     if (!preg_match("/^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$/", $domain_array[$i])) {
       return false;
     }
   }
 }
 return true;
}

include "config.php";
global $_CONFIG;
define("MONO_ON", 1);
require "class/class_db_{$_CONFIG['driver']}.php";
$db=new database;
$db->configure($_CONFIG['hostname'],
$_CONFIG['username'],
$_CONFIG['password'],
$_CONFIG['database'],
$_CONFIG['persistent']);
$db->connect();
$c=$db->connection_id;
if(!$_GET['password']) { die("<font color='red'>Invalid - Blank</font>"); }
if(!valid_email($_GET['password'])) { die("<font color='red'>Invalid - Bad Format</font>"); }
$un=$_GET['password'];
$q=$db->query("SELECT * FROM users WHERE email='$un'");
if($db->num_rows($q)) { die("<font color='red'>Invalid - Already In Use</font>"); }
print "<font color='green'>Valid</font>";
?>

 

 

and the original is ::

 

<?php
//thx to http://www.phpit.net/code/valid-email/ for valid_email
function valid_email($email) {
 // First, we check that there's one @ symbol, and that the lengths are right
 if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $email)) {
   // Email invalid because wrong number of characters in one section, or wrong number of @ symbols.
   return false;
 }
 // Split it into sections to make life easier
 $email_array = explode("@", $email);
 $local_array = explode(".", $email_array[0]);
 for ($i = 0; $i < sizeof($local_array); $i++) {
    if (!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$", $local_array[$i])) {
     return false;
   }
 }  
 if (!ereg("^\[?[0-9\.]+\]?$", $email_array[1])) { // Check if domain is IP. If not, it should be valid domain name
   $domain_array = explode(".", $email_array[1]);
   if (sizeof($domain_array) < 2) {
       return false; // Not enough parts to domain
   }
   for ($i = 0; $i < sizeof($domain_array); $i++) {
     if (!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$", $domain_array[$i])) {
       return false;
     }
   }
 }
 return true;
}

include "config.php";
global $_CONFIG;
define("MONO_ON", 1);
require "class/class_db_{$_CONFIG['driver']}.php";
$db=new database;
$db->configure($_CONFIG['hostname'],
$_CONFIG['username'],
$_CONFIG['password'],
$_CONFIG['database'],
$_CONFIG['persistent']);
$db->connect();
$c=$db->connection_id;
if(!$_GET['password']) { die("<font color='red'>Invalid - Blank</font>"); }
if(!valid_email($_GET['password'])) { die("<font color='red'>Invalid - Bad Format</font>"); }
$un=$_GET['password'];
$q=$db->query("SELECT * FROM users WHERE email='$un'");
if($db->num_rows($q)) { die("<font color='red'>Invalid - Already In Use</font>"); }
print "<font color='green'>Valid</font>";
?>
Edited by snaketooth22
Link to comment
Share on other sites

You don't need valid_email PHP already has one built in

 

filter_var($var, FILTER_VALIDATE_EMAIL)

where does it have that mate ??,.. am i missing something ??, ..

plus i want it to show in the register page so the user knows what they are entering is valid

like it does or used to in every mccode V2 script

Link to comment
Share on other sites

Take all this

//thx to http://www.phpit.net/code/valid-email/ for valid_email
function valid_email($email) {
 // First, we check that there's one @ symbol, and that the lengths are right
 if (!preg_match("/^[^@]{1,64}@[^@]{1,255}$/", $email)) {
   // Email invalid because wrong number of characters in one section, or wrong number of @ symbols.
   return false;
 }
 // Split it into sections to make life easier
 $email_array = explode("@", $email);
 $local_array = explode(".", $email_array[0]);
 for ($i = 0; $i < sizeof($local_array); $i++) {
   if (!preg_match("/^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$/", $local_array[$i])) {
     return false;
   }
 }  
 if (!preg_match("/^\[?[0-9\.]+\]?$/", $email_array[1])) { // Check if domain is IP. If not, it should be valid domain name
   $domain_array = explode(".", $email_array[1]);
   if (sizeof($domain_array) < 2) {
       return false; // Not enough parts to domain
   }
   for ($i = 0; $i < sizeof($domain_array); $i++) {
     if (!preg_match("/^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$/", $domain_array[$i])) {
       return false;
     }
   }
 }
 return true;
}

and do this:

function valid_email($email)
{
   if (!filter_var($email, FILTER_VALIDATE_EMAIL))
       return false;
   return true;
}
Link to comment
Share on other sites

Oh my god it was that simple,..

haaha ,. thanks alot for that,,.. ill remember that in future :)

For a lot of things, just remember not everything filter_var() and filter_input() can be a really great friend of yours. It has quite a bit of nice features like defaults if the input returns false or even other settings like what you want to allow or not.

Link to comment
Share on other sites

For a lot of things, just remember not everything filter_var() and filter_input() can be a really great friend of yours. It has quite a bit of nice features like defaults if the input returns false or even other settings like what you want to allow or not.

yeah the updated version compared to the original is so much more easier to understand and know what its doing,. that original one was just madness

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...