Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Parse error: parse error, unexpected $ in...

Posted on 2007-04-10
7
235 Views
Last Modified: 2007-04-10
Can't figure this one out, I've been looking at this for 2 hours.

http://www.austinmetrobaseball.com/gamechange.txt
0
Comment
Question by:EddieShipman
7 Comments
 
LVL 24

Expert Comment

by:glcummins
ID: 18885131
Can you post the full error message? All we received was "parse error, unexpected $ in..."
0
 
LVL 29

Accepted Solution

by:
TeRReF earned 500 total points
ID: 18885180
Change these lines:

  if ( isset($_POST["gameid_1"]) ) {
    $sql = "SELECT h.email AS hemail, v.email AS vemail ";
    $sql = $sql. "FROM games AS g ";
    $sql = $sql. "JOIN teams AS v ON ( v.id = g.visitorid ) ";
    $sql = $sql. "JOIN teams AS h ON ( h.id = g.homeid ) ";
    $sql = $sql. "WHERE g.gamenum = ".$_POST["gameid_1"];
    $query = $db->query($sql);
    if ($db->num_rows($query) > 0) {
      list($hemail1, $vemail1)=$db->fetch_row($query);
    }
    $sql = "SELECT gamenum, ";
    $sql = $sql. "       DATE_FORMAT(gamedate, \"%a %b %d  %l:%i%p\"), ";
    $sql = $sql. "       v.teamname AS visitor, ";
    $sql = $sql. "       h.teamname AS home, ";
    $sql = $sql. "       f.field_name ";
    $sql = $sql. "FROM games AS g ";
    $sql = $sql. "JOIN teams AS v ON ( v.id = g.visitorid ) ";
    $sql = $sql. "JOIN teams AS h ON ( h.id = g.homeid ) ";
    $sql = $sql. "JOIN _fields AS f ON (f.id = g.fieldid )";
    $sql = $sql. "WHERE g.gamenum =".$game_num1;
    $query = $db->query($sql);
    if ($db->num_rows($query) > 0) {
      list($gamenum1, $gamedate1, $visitteam1, $hometeam1, $field_name1)=$db->fetch_row($query);
  }
  if ( isset($_POST["gameid_2"]) ) {
    $sql =  "SELECT h.email AS hemail, v.email AS vemail ";
    $sql = $sql. "FROM games AS g ";
    $sql = $sql. "JOIN teams AS v ON ( v.id = g.visitorid ) ";
    $sql = $sql. "JOIN teams AS h ON ( h.id = g.homeid ) ";
    $sql = $sql. "WHERE g.gamenum = ".$_POST["gameid_2"];
    $query = $db->query($sql);
    if ($db->num_rows($query) > 0) {
      list($hemail2, $vemail2)=$db->fetch_row($query);
    }
    $sql = "SELECT gamenum, ";
    $sql = $sql. "       DATE_FORMAT(gamedate, \"%a %b %d  %l:%i%p\"), ";
    $sql = $sql. "       v.teamname AS visitor, ";
    $sql = $sql. "       h.teamname AS home, ";
    $sql = $sql. "       f.field_name ";
    $sql = $sql. "FROM games AS g ";
    $sql = $sql. "JOIN teams AS v ON ( v.id = g.visitorid ) ";
    $sql = $sql. "JOIN teams AS h ON ( h.id = g.homeid ) ";
    $sql = $sql. "JOIN _fields AS f ON (f.id = g.fieldid )";
    $sql = $sql. "WHERE g.gamenum =".$game_num2;
    $query = $db->query($sql);
    if ($db->num_rows($query) > 0) {
      list($gamenum2, $gamedate2, $visitteam2, $hometeam2, $field_name2)=$db->fetch_row($query);
    }



into:

  if ( isset($_POST["gameid_1"]) ) {
    $sql = "SELECT h.email AS hemail, v.email AS vemail ";
    $sql = $sql. "FROM games AS g ";
    $sql = $sql. "JOIN teams AS v ON ( v.id = g.visitorid ) ";
    $sql = $sql. "JOIN teams AS h ON ( h.id = g.homeid ) ";
    $sql = $sql. "WHERE g.gamenum = ".$_POST["gameid_1"];
    $query = $db->query($sql);
    if ($db->num_rows($query) > 0) {
      list($hemail1, $vemail1)=$db->fetch_row($query);
    }
    $sql = "SELECT gamenum, ";
    $sql = $sql. "       DATE_FORMAT(gamedate, \"%a %b %d  %l:%i%p\"), ";
    $sql = $sql. "       v.teamname AS visitor, ";
    $sql = $sql. "       h.teamname AS home, ";
    $sql = $sql. "       f.field_name ";
    $sql = $sql. "FROM games AS g ";
    $sql = $sql. "JOIN teams AS v ON ( v.id = g.visitorid ) ";
    $sql = $sql. "JOIN teams AS h ON ( h.id = g.homeid ) ";
    $sql = $sql. "JOIN _fields AS f ON (f.id = g.fieldid )";
    $sql = $sql. "WHERE g.gamenum =".$game_num1;
    $query = $db->query($sql);
    if ($db->num_rows($query) > 0) {
      list($gamenum1, $gamedate1, $visitteam1, $hometeam1, $field_name1)=$db->fetch_row($query);
    }
  }
  if ( isset($_POST["gameid_2"]) ) {
    $sql =  "SELECT h.email AS hemail, v.email AS vemail ";
    $sql = $sql. "FROM games AS g ";
    $sql = $sql. "JOIN teams AS v ON ( v.id = g.visitorid ) ";
    $sql = $sql. "JOIN teams AS h ON ( h.id = g.homeid ) ";
    $sql = $sql. "WHERE g.gamenum = ".$_POST["gameid_2"];
    $query = $db->query($sql);
    if ($db->num_rows($query) > 0) {
      list($hemail2, $vemail2)=$db->fetch_row($query);
    }
    $sql = "SELECT gamenum, ";
    $sql = $sql. "       DATE_FORMAT(gamedate, \"%a %b %d  %l:%i%p\"), ";
    $sql = $sql. "       v.teamname AS visitor, ";
    $sql = $sql. "       h.teamname AS home, ";
    $sql = $sql. "       f.field_name ";
    $sql = $sql. "FROM games AS g ";
    $sql = $sql. "JOIN teams AS v ON ( v.id = g.visitorid ) ";
    $sql = $sql. "JOIN teams AS h ON ( h.id = g.homeid ) ";
    $sql = $sql. "JOIN _fields AS f ON (f.id = g.fieldid )";
    $sql = $sql. "WHERE g.gamenum =".$game_num2;
    $query = $db->query($sql);
    if ($db->num_rows($query) > 0) {
      list($gamenum2, $gamedate2, $visitteam2, $hometeam2, $field_name2)=$db->fetch_row($query);
    }
  }
0
 
LVL 27

Expert Comment

by:yodercm
ID: 18885194
Well, for one thing, this line looks strange to me...

  $db = new dbstuff;

I don't think that's correct php syntax.
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 26

Author Comment

by:EddieShipman
ID: 18885432
[quote]$db = new dbstuff;[/quote]

That is a db access class that I got from phpclasses.org.
0
 
LVL 26

Author Comment

by:EddieShipman
ID: 18885437
You didn't have to post all that code, all you had to do was say that I needed
a closing } for the if here:

if ( isset($_POST["gameid_1"]) ) {
  .
  .
  if ($db->num_rows($query) > 0) {
    list($gamenum1, $gamedate1, $visitteam1, $hometeam1, $field_name1)=$db->fetch_row($query);
  }
}
0
 
LVL 26

Author Comment

by:EddieShipman
ID: 18885463
[quote]Can you post the full error message? All we received was "parse error, unexpected $ in..."[/quote]
This is the EXACT message sent:

Parse error: parse error, unexpected $ in /home/austin1/public_html/gamechange.php on line 282
0
 
LVL 29

Expert Comment

by:TeRReF
ID: 18885817
Sometimes it's easier to just post some more code instead of explaining where the closing }'s need to be added :)
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question