1.11M Members

preg_replace() error

//if user is not loged in
    header("location: admin_login.php");
//check if user exists in database
$managerID = preg_replace('#[^0-9#]i','',$_SESSION["id"]); //decype the id
$manager = preg_replace('#[^A-Za-z0-9]#i','',$_SESSION["manager"]);
$password = preg_replace('#[^A-Za-z0-9]#i','',$_SESSION["password"]);

include "../storescripts/connect_to_mysql.php";
$sql = mysql_query("SELECT * FROM admin WHERE id='$managerID' AND username='$manager' AND password='$password' LIMIT 1");
//make sure person exists in database
$existCount = msql_num_rows($sql);
if($existCount == 0)
    header("location: ../index.php");

Warning: preg_replace() [function.preg-replace]: Unknown modifier ']' in C:\xampp\htdocs\E-COMMERCE\admin\index.php on line 10

Warning: include(../storescripts/connect_to_mysql.php) [function.include]: failed to open stream: No such file or directory in C:\xampp\htdocs\E-COMMERCE\admin\index.php on line 14

Warning: include() [function.include]: Failed opening '../storescripts/connect_to_mysql.php' for inclusion (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\E-COMMERCE\admin\index.php on line 14

Fatal error: Call to undefined function msql_num_rows() in C:\xampp\htdocs\E-COMMERCE\admin\index.php on line 17

line 10:
$managerID = preg_replace('#[^0-9#]i','',$_SESSION["id"]); //decype the id
line 14:
include "../storescripts/connect_to_mysql.php";
line 17:
$existCount = msql_num_rows($sql);


Looking at what you have in the other preg_replace functions, shouldn't #[^0-9#]i actually be #[^0-9]#i

With regard to your include files, that is down to you to check the paths to the files are correct I am afraid.

As for the mysql_num_rows issue, your query will presumably not work until you have resolved the preg_replace issue.

Question Answered as of 1 Year Ago by simplypixie


Isn't it about time forums rewarded their contributors?

Earn rewards points for helping others. Gain kudos. Cash out. Get better answers yourself.

It's as simple as contributing editorial or replying to discussions labeled or OP Kudos

This question has already been solved: Start a new discussion instead
Start New Discussion
Tags Related to this Article