Code Question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jpmax47
Forum Newbie
Posts: 4
Joined: Tue Aug 30, 2011 5:56 pm

Code Question

Post 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
Last edited by jpmax47 on Tue Aug 30, 2011 7:46 pm, edited 1 time in total.
User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

Re: Code Question

Post by McInfo »

See the first character on line 10.
jpmax47
Forum Newbie
Posts: 4
Joined: Tue Aug 30, 2011 5:56 pm

Re: Code Question

Post by jpmax47 »

Thanks that was just an error in my posting - it doesn't appear in the code so I'll remove it.
User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

Re: Code Question

Post by McInfo »

One double-quote character,

Code: Select all

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

Code: Select all

''
jpmax47
Forum Newbie
Posts: 4
Joined: Tue Aug 30, 2011 5:56 pm

Re: Code Question

Post 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.
jpmax47
Forum Newbie
Posts: 4
Joined: Tue Aug 30, 2011 5:56 pm

Re: Code Question

Post 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
Post Reply