?
Solved

Parse Errors

Posted on 2006-05-10
7
Medium Priority
?
220 Views
Last Modified: 2010-05-18
I bought a book from Wiley Publishing which included a ton of PHP / MySQL Examples.

None of the code seems to work on a Windows or Linux box.

In the following code lines 9, 10, 15, 18 and 44 all state that I have a Parse error. The other consistent part is this;
session_user()-> in all 5 lines

Any Help here would be Great and Thanks!


<?php
require_once('header.php');
print start_page('Project Management Example');

$query = 'select p.project_id, p.project, p.due_dt
            , if(p.owner_id=?,1,0) as is_owner
      from projects p
';
$bind = array(session_user()->user_id);
if (!session_user()->is_admin())
{
      $query .= ' , project_user_map m
            where p.project_id = m.project_id and m.user_id = ?
      ';
      $bind[] = session_user()->user_id;
}
$query .= ' order by is_owner desc, p.due_dt ';
$rows = session_user()->dbh()->getAll($query, $bind);

$links = array();
$done_id = Status::status_id('done');
$cancelled_id = Status::status_id('cancelled');
$slipped_id = Status::status_id('slipped');
foreach ($rows as $row)
{
      extract($row, EXTR_OVERWRITE|EXTR_PREFIX_ALL, 'p');
      $tlinks = array();
      $tlinks[] = anchor_tag(
            'tasks/cal.php?project_id='.$p_project_id
            , 'Calendar'
      );
      $tlinks[] = anchor_tag(
            'tasks/list.php?project_id='.$p_project_id
            , 'Task List'
      );
      $query = 'select t.*, u.user as owner
            from tasks t left join users u on t.owner_id = u.user_id
            where t.project_id = ?
                  and t.status_id <> ?
                  and (t.due_dt >= curdate() - interval 3 day
                        and t.due_dt <= curdate() + interval 3 day)
      ';
      $bind = array($p_project_id, $cancelled_id);
      $events = session_user()->dbh()->getAll($query,$bind);
0
Comment
Question by:resolvco
7 Comments
 
LVL 49

Expert Comment

by:Roonaan
ID: 16647577
Shouldn't it be something like
$session_user = session_user();

$bind = array($session_user->id);

-r-
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 1500 total points
ID: 16647582
what version of PHP do you use?
i think this syntax only works as from PHP 5 on, but not sure...
0
 
LVL 13

Expert Comment

by:kamermans
ID: 16648198
I think we would need to see the function 'session_user()' to be able to solve this one, since it is not a built in PHP function.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:resolvco
ID: 16649658
4.3
0
 

Author Comment

by:resolvco
ID: 16654441
Okay also, on those lines shouldn't the operator be => and not ->?

When Changing it and running it I get:

"unexpected t_double_arrow"

Here's the Function:

<?php
function session_user()
{
      check_session();
      if (!isset($_SESSION))
            global $_SESSION;

      if (empty($_SESSION['user']) || !($_SESSION['user'] instanceof User))
            $_SESSION['user'] = new User;

      return $_SESSION['user'];

}
?>
0
 
LVL 13

Expert Comment

by:kamermans
ID: 16654506
The '->' operator is the PHP Object Oriented Programming (OOP) method for accessing class methods/properties/etc... but can also be used for calling functions.  I'm not sure what they're trying to do in this script.  I agree with AngelIII - I don't think you can use this OOP method in PHP < 5.  I'm also not quite sure how to translate it to PHP 4.x.
0
 

Author Comment

by:resolvco
ID: 16658854
That was it, PHP5. The Book I got the samples from was written previous to PHP5, why they would then put a CD together and release the code with PHP5 projects!?!?!?
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

This article discusses how to create an extensible mechanism for linked drop downs.
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses
Course of the Month16 days, 15 hours left to enroll

862 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