Code Question
Posted: Tue Aug 30, 2011 6:22 pm
I am following a video tutorial on developing a E-commerce site. I ran across a problem trying to create an administrator log in page. The code is as follows:
1) <?php
2) session_start();
3) if(!isset($SESSION["manager"])){
4) header("location: admin_login.php");
5) exit();
6) }
7)

9) // Be sure to check that this manager SESSION value is in fact in the database
10) $managerID = preg_replace('#[^0-9]#i',",$_SESSION["id"]); //filter everything but numbers and letters
11) $manager=preg_replace('#[^A-Za-z0-9]#i',",$_SESSION["manger"]); //filter everything but numbers and letters
12) $password=preg_replace('#[^A-Za-z0-9]#i',$_SESSION["password"]); //filter everything but numbers and letters
13) //Run mySQL query to be sure that this person is an admin and that their password session var equals the database information
14) //Connect to the MySQL database
15) include"../storescripts/connect_to_mysql.php";
16) $sql=mysql_query("
17) SELECT * FROM admin
18) WHERE id='$managerID'
19) AND username='$manager'
20) AND password='$password'
21) LIMIT 1
22) ");//query the person
23) //-----MAKE SURE PERSON EXISTS IN DATABASE ------
24) $existCount=mysql_num_rows($sql);//count the row nums
25) if($existCount==0){//evaluate the count
26) header("location:../index.php");
27) exit();
28)}
29)?>
This seems to work for the tutorial but when I try to run this code on my page, I get the following error:
Parse error: parse error in C:\wamp\www\tms01\storeAdmin\admin_login.php on line 10
I thought it was because there is an extra " in line 10 but just can't figure it out
1) <?php
2) session_start();
3) if(!isset($SESSION["manager"])){
4) header("location: admin_login.php");
5) exit();
6) }
7)
9) // Be sure to check that this manager SESSION value is in fact in the database
10) $managerID = preg_replace('#[^0-9]#i',",$_SESSION["id"]); //filter everything but numbers and letters
11) $manager=preg_replace('#[^A-Za-z0-9]#i',",$_SESSION["manger"]); //filter everything but numbers and letters
12) $password=preg_replace('#[^A-Za-z0-9]#i',$_SESSION["password"]); //filter everything but numbers and letters
13) //Run mySQL query to be sure that this person is an admin and that their password session var equals the database information
14) //Connect to the MySQL database
15) include"../storescripts/connect_to_mysql.php";
16) $sql=mysql_query("
17) SELECT * FROM admin
18) WHERE id='$managerID'
19) AND username='$manager'
20) AND password='$password'
21) LIMIT 1
22) ");//query the person
23) //-----MAKE SURE PERSON EXISTS IN DATABASE ------
24) $existCount=mysql_num_rows($sql);//count the row nums
25) if($existCount==0){//evaluate the count
26) header("location:../index.php");
27) exit();
28)}
29)?>
This seems to work for the tutorial but when I try to run this code on my page, I get the following error:
Parse error: parse error in C:\wamp\www\tms01\storeAdmin\admin_login.php on line 10
I thought it was because there is an extra " in line 10 but just can't figure it out