Page 1 of 1

Code Question

Posted: Tue Aug 30, 2011 6:22 pm
by jpmax47
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)
8)
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

Re: Code Question

Posted: Tue Aug 30, 2011 7:26 pm
by McInfo
See the first character on line 10.

Re: Code Question

Posted: Tue Aug 30, 2011 7:45 pm
by jpmax47
Thanks that was just an error in my posting - it doesn't appear in the code so I'll remove it.

Re: Code Question

Posted: Tue Aug 30, 2011 8:19 pm
by McInfo
One double-quote character,

Code: Select all

"
is not the same as two single-quote characters,

Code: Select all

''

Re: Code Question

Posted: Tue Aug 30, 2011 9:21 pm
by jpmax47
good point however, this is not the case. I noticed that there is a difference between " and ' '. In dreamweaver cs4 coding, there seems to be a bigger space between two single ' . I did try changing the quotes and that didn't solve the problem.

Re: Code Question

Posted: Tue Aug 30, 2011 9:30 pm
by jpmax47
I changed the font and now I get what you suggested. Still having problems with the code but I don't think what I posted will be an issue. Thanks for your help :D