Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 09-01-2007, 01:57 PM Parse Error
Novice Talker

Posts: 5
Name: Jon
Trades: 0
I have run into a Parse Error while I was coding a web site for my father-in-law. It is a basic error, yet I can't seem to find the problem. below is the error, and the code leading up to the error.

Parse error: syntax error, unexpected T_IS_EQUAL, expecting ',' or ')' on line 6

Code:
<?php
// Page information will go here
if ($_GET['page'] == 'company') {
    if (isset($_GET['area'] == 'staff')) {
$query = "SELECT * FROM staff";
$result = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_array($result) or die(mysql_error());


From that last line, it goes into echoing HTML to form a table, and create my pages. I have used these lines of code in so many pages, why won't it work. On a scale of 1-5, I'm about a 4 on PHP, so maybe I am missing something? Could it be something farther in my code?


j.edney is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 09-01-2007, 02:07 PM Re: Parse Error
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,918
Name: Keith Marshall
Location: Connecticut
Trades: 0
Inyour example above, you are not closing your if statements:

PHP Code:
<?php
  
  
// Page information will go here
  
if ($_GET['page'] == 'company')
  {
    if (isset(
$_GET['area'] == 'staff'))
    {
      
$query "SELECT * FROM staff";
      
$result mysql_query($query) or die(mysql_error());
      
$row mysql_fetch_array($result) or die(mysql_error());
    }
  }
  
?>
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 09-01-2007, 02:28 PM Re: Parse Error
Novice Talker

Posts: 5
Name: Jon
Trades: 0
I have checked the statement, I still recieve the error. Here is more of the code.

Code:
 
<?php
// Page information will go here
if ($_GET['page'] == 'company')
{
 if (isset($_GET['area'] == 'staff') ) 
 {
 $query="SELECT * FROM staff";
 $result = mysql_query($query) or die(mysql_error());
 $row = mysql_fetch_array($result) or die(mysql_error());
 echo ("HTML IS GOING HERE"); }
 }
 
 elseif (isset($_GET['area'] == 'testimonials') ) 
 {
 $query="SELECT * FROM testimonials";
 $result = mysql_query($query) or die(mysql_error());
 $row = mysql_fetch_array($result) or die(mysql_error());
 echo ("HTML IS GOING HERE");
 
 }elseif (isset($_GET['area'] == 'contact') ) 
 {
 $query="SELECT * FROM contact";
 $result = mysql_query($query) or die(mysql_error());
 $row = mysql_fetch_array($result) or die(mysql_error());
 echo ("HTML IS GOING HERE");

 }else {
This code just continues the same coding, just different values. Any ideas where the problem is?
j.edney is offline
Reply With Quote
View Public Profile
 
Old 09-01-2007, 02:31 PM Re: Parse Error
JamieLewis's Avatar
Pretty Much a Big Deal...

Latest Blog Post:
Gooie
Posts: 385
Name: Jamie Lewis
Location: UK
Trades: 0
your brackets on the second if statement are misplaced

should be
if( isset($_GET['area']) =='staff')

Jamie
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
JamieLewis is offline
Reply With Quote
View Public Profile Visit JamieLewis's homepage!
 
Old 09-01-2007, 02:48 PM Re: Parse Error
Novice Talker

Posts: 5
Name: Jon
Trades: 0
Thank you, Jamie. Looks like that was the problem, throughout my whole page of code. I can't believe I misplaced a ). Thanks!
j.edney is offline
Reply With Quote
View Public Profile
 
Old 09-01-2007, 03:22 PM Re: Parse Error
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,918
Name: Keith Marshall
Location: Connecticut
Trades: 0
Quote:
Originally Posted by JamieLewis View Post
your brackets on the second if statement are misplaced

should be
if( isset($_GET['area']) =='staff')

Jamie

Oops, missed that!
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 09-01-2007, 03:33 PM Re: Parse Error
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
You will probally be better off using Switch for that lot of code. it will use alot less code, and make it a bit easier to read and understand.

If you want any help, i could probally help you
__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Old 09-01-2007, 04:55 PM Re: Parse Error
Defies a Status

Posts: 1,606
Trades: 0
Quote:
Originally Posted by j.edney View Post
Thank you, Jamie. Looks like that was the problem, throughout my whole page of code. I can't believe I misplaced a ). Thanks!

And if I had a beer for everytime I forgot the d*** semicolon we would have a real labor day party here.
__________________
Colbyt

Please login or register to view this content. Registration is FREE
colbyt is offline
Reply With Quote
View Public Profile
 
Old 09-01-2007, 06:14 PM Re: Parse Error
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
I prefer Vodka
__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Old 09-04-2007, 07:01 AM Re: Parse Error
Galaxian's Avatar
Rich Powell

Posts: 842
Name: Rich Powell
Location: United Kingdom
Trades: 0
Quote:
Originally Posted by JamieLewis View Post
your brackets on the second if statement are misplaced

should be
if( isset($_GET['area']) =='staff')

Jamie
Why use isset?

Should be just

if($_GET['area'] == 'staff')
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Please help get the new
Please login or register to view this content. Registration is FREE
forum started for Webmasters like you!

Galaxian is offline
Reply With Quote
View Public Profile Visit Galaxian's homepage!
 
Old 09-04-2007, 07:45 AM Re: Parse Error
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
i think its to check that $_GET['area'] is staff??
__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Old 09-04-2007, 10:20 AM Re: Parse Error
Galaxian's Avatar
Rich Powell

Posts: 842
Name: Rich Powell
Location: United Kingdom
Trades: 0
Quote:
Originally Posted by dansgalaxy View Post
i think its to check that $_GET['area'] is staff??
You don't need isset for that, wouldn't that code be incorrect? isset returns true or false.

If we use $_GET['area'] == 'staff' without isset that should be just fine.

isset is only used to check if it's set, not what the content is.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Please help get the new
Please login or register to view this content. Registration is FREE
forum started for Webmasters like you!

Galaxian is offline
Reply With Quote
View Public Profile Visit Galaxian's homepage!
 
Reply     « Reply to Parse Error
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.48255 seconds with 12 queries