We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,721 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

preg_replace() error

<?php
session_start();
//if user is not loged in
if(!isset($_SESSION["manager"])) 
{
    header("location: admin_login.php");
    exit();
}
//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");
    exit();
}
?>

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);

2
Contributors
2
Replies
7 Hours
Discussion Span
6 Months Ago
Last Updated
3
Views
Question
Answered
hwoarang69
Posting Pro
569 posts since Feb 2012
Reputation Points: 6
Solved Threads: 0
Skill Endorsements: 7

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.

simplypixie
Practically a Master Poster
642 posts since Oct 2010
Reputation Points: 157
Solved Threads: 118
Skill Endorsements: 5
Question Answered as of 6 Months Ago by simplypixie

thanks

hwoarang69
Posting Pro
569 posts since Feb 2012
Reputation Points: 6
Solved Threads: 0
Skill Endorsements: 7

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.0812 seconds using 2.66MB