472,811 Members | 1,175 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,811 software developers and data experts.

Parse Error - Unexpected T_OBJECT_OPERATOR

I'm trying to run a script and it's throwing the following error:
Expand|Select|Wrap|Line Numbers
  1. Parse error: syntax error, unexpected T_OBJECT_OPERATOR in openfile.php on line 41
  2.  
Here is the openfile.php file and I have bolded line 41. Any ideas/help would be greatly appreciated!
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. /* 
  4.   This file is responsible for the download of the files
  5. */
  6.  
  7. require_once('../../../wp-config.php');
  8.  
  9. global $user_ID, $wpdb, $table_prefix;
  10.  
  11. require_once(ABSPATH . 'wp-admin/upgrade-functions.php'); 
  12.  
  13. include_once("uploader_functions.php");
  14.  
  15. $id = (int) $_GET['file'];
  16.  
  17. $result = @$wpdb->get_row("SELECT fileName, type, title, downloads
  18.                             FROM ".$table_prefix."document
  19.                             WHERE id = ".$id."
  20.                            ;");
  21.  
  22. if(!isset($result->title)){
  23.  
  24.   $info = get_bloginfo("url");
  25.  
  26.   header("Location: ".$info."/wp-content/plugins/wp-publications-archive/notFound.php");
  27.  
  28.   return;
  29.  
  30.  
  31. $downloads = $result->downloads + 1;
  32. $wpdb->query("UPDATE ".$table_prefix."document 
  33.                     SET downloads = ".$downloads."
  34.                     WHERE id = ".$id.";");
  35.  
  36. $fTitle = $result->title;                         
  37.  
  38. $fPath = $result->fileName;
  39.  
  40. $fType = wpup_upGetType($result->type)->extName;
  41.  
  42. $fName = basename($fPath); //Get filename //thanks to brian.m.turnbull
  43.  
  44. $origname = preg_replace('/_#_#\d*/','',$fName); //Remove the _#_#$id //thanks to brian.m.turnbull
  45.  
  46. $permission = "all";
  47.  
  48. $plugin_name = "wp_uploader";
  49.  
  50. if (class_exists("userGroups"))
  51.   $user = new userGroups;
  52.  
  53. if (class_exists("userGroups") && $user->ugHasAccess($user_ID, $id, $permission, $plugin_name)){
  54.  
  55.   header('Content-type: "'.$fType.'"');
  56.  
  57.   header('Content-Disposition: attachment; filename="'.$origname.'"'); //thanks to brian.m.turnbull
  58.  
  59.   readfile($fPath);
  60.  
  61. }  
  62.  
  63. if (class_exists("userGroups") && !$user->ugHasAccess($user_ID, $id, $permission, $plugin_name)){
  64.  
  65.   $info = get_bloginfo("url");
  66.  
  67.   header("Location: ".$info."/wp-content/plugins/wp-publications-archive/access.php");
  68.  
  69. }
  70.  
  71. if (!class_exists("userGroups")){
  72.  
  73.   header('Content-type: "'.$fType.'"');
  74.  
  75.   header('Content-Disposition: attachment; filename="'.$origname.'"'); //thanks to brian.m.turnbull
  76.  
  77.   readfile($fPath);
  78.  
  79. }
  80.  
  81. ?>
  82.  
Sep 17 '07 #1
5 13948
Atli
5,058 Expert 4TB
Hi Devereaux. Welcome to The Scripts!

Are you sure the result you are getting from the wpup_upGetType() function is a valid object? Is it possible that is returns something else, like say false if it fails?

Also, please use [code] tags when posting code. It is impossible to read it without them.
Sep 17 '07 #2
Thanks so much for the reply. I must admit I'm a bit of a hack with PHP so forgive my lack of true expertise. However, I'm fairly positive of the result. The function itself is in uploader_functions.php and is as follows:

Expand|Select|Wrap|Line Numbers
  1. /*
  2. * Funtion used to get all the details of a file by the given id
  3. * @param id of the file type
  4. * @return array contaninning all the details of the given file type
  5. */
  6. function wpup_upGetType($id){
  7.   global $wpdb, $table_prefix;
  8.   return $type = $wpdb->get_row("SELECT *
  9.                               FROM ".$table_prefix."type
  10.                               WHERE id = ".$id."
  11.                               ;");
  12. }
  13.  
Sorry about not using the code tags before. I am using PHP 4.4.4, Apache 1.3.37 and MySQL 4.1.22

If there is more that I can do to help debug please let me know and I will work through that. Thanks again!!!
Sep 17 '07 #3
Alright I resolved my own issue. The single line of code had to be split into to lines as shown below in the new openfile.php file. Thanks for taking a look though - much appreciated!

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. /* 
  4.   This file is responsible for the download of the files
  5. */
  6.  
  7. require_once('../../../wp-config.php');
  8.  
  9. global $user_ID, $wpdb, $table_prefix;
  10.  
  11. require_once(ABSPATH . 'wp-admin/upgrade-functions.php'); 
  12.  
  13. include_once("uploader_functions.php");
  14.  
  15. $id = (int) $_GET['file'];
  16.  
  17. $result = @$wpdb->get_row("SELECT fileName, type, title, downloads
  18.                             FROM ".$table_prefix."document
  19.                             WHERE id = ".$id."
  20.                            ;");
  21.  
  22. if(!isset($result->title)){
  23.  
  24.   $info = get_bloginfo("url");
  25.  
  26.   header("Location: ".$info."/wp-content/plugins/wp-publications-archive/notFound.php");
  27.  
  28.   return;
  29.  
  30.  
  31. $downloads = $result->downloads + 1;
  32. $wpdb->query("UPDATE ".$table_prefix."document 
  33.                     SET downloads = ".$downloads."
  34.                     WHERE id = ".$id.";");
  35.  
  36. $fTitle = $result->title;                         
  37.  
  38. $fPath = $result->fileName;
  39.  
  40. $fType = wpup_upGetType($result->type);
  41. $fType = $result->extName;
  42.  
  43. $fName = basename($fPath); //Get filename //thanks to brian.m.turnbull
  44.  
  45. $origname = preg_replace('/_#_#\d*/','',$fName); //Remove the _#_#$id //thanks to brian.m.turnbull
  46.  
  47. $permission = "all";
  48.  
  49. $plugin_name = "wp_uploader";
  50.  
  51. if (class_exists("userGroups"))
  52.   $user = new userGroups;
  53.  
  54. if (class_exists("userGroups") && $user->ugHasAccess($user_ID, $id, $permission, $plugin_name)){
  55.  
  56.   header('Content-type: "'.$fType.'"');
  57.  
  58.   header('Content-Disposition: attachment; filename="'.$origname.'"'); //thanks to brian.m.turnbull
  59.  
  60.   readfile($fPath);
  61.  
  62. }  
  63.  
  64. if (class_exists("userGroups") && !$user->ugHasAccess($user_ID, $id, $permission, $plugin_name)){
  65.  
  66.   $info = get_bloginfo("url");
  67.  
  68.   header("Location: ".$info."/wp-content/plugins/wp-publications-archive/access.php");
  69.  
  70. }
  71.  
  72. if (!class_exists("userGroups")){
  73.  
  74.   header('Content-type: "'.$fType.'"');
  75.  
  76.   header('Content-Disposition: attachment; filename="'.$origname.'"'); //thanks to brian.m.turnbull
  77.  
  78.   readfile($fPath);
  79.  
  80. }
  81.  
  82. ?> 
  83.  
Sep 17 '07 #4
Well, this doesn't work after all - it does but it's inconsistent. The files will open but only some of the time. :-) Very strange....
Sep 17 '07 #5
Atli
5,058 Expert 4TB
Well, this doesn't work after all - it does but it's inconsistent. The files will open but only some of the time. :-) Very strange....
I see.

Are you getting any errors?

Try checking it the $result object has a value for 'extName'.
Expand|Select|Wrap|Line Numbers
  1. print_r($result);
  2.  
Sep 17 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: sky2070 | last post by:
Parse error: parse error, unexpected T_OBJECT_OPERATOR, expecting ')' in c:\inetpub\wwwroot\session.php on line 19 can anyone tell me what is wrong with this code??? <? // Define the Session...
3
by: Marten van Urk | last post by:
I got the following error in my page Parse error: parse error, unexpected T_ELSE in line 25 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Club</title>...
6
by: Ehartwig | last post by:
I recently created a script for user verification, solved my emailing issues, and then re-created the script in order to work well with the new PHP 5 that I installed on my server. After...
8
by: Wescotte | last post by:
The error message Parse error: syntax error, unexpected $end in FILE on line X is one I run into frequently and I know the cause is I missed an ending quote. Is there an easy way to determine...
5
by: Anna MZ | last post by:
I am new to php and have written the following mysql code to enter the details of a new user in the admin subdomain of my website: $sql = "INSERT INTO 'users' ('userid', 'username', 'upassword')...
1
by: soidariti | last post by:
database error - parse error, unexpected $, expecting kEND AddUserAuthorisationToUsers.rb migration file 1. class AddUserAuthorisationToUsers < ActiveRecord::Migration 2. def self.up ...
1
epots9
by: epots9 | last post by:
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /var/www/html/xxx.php on line xxx I get that message when i try to run my...
3
by: nazgul42 | last post by:
I am writing a very simple login script for a website that I am also writing, but when I try to run it, the only error I get is: Parse error: parse error, unexpected $ in...
2
by: Lawrence Krubner | last post by:
Imagine a template system that works by getting a file, as a string, and then putting it through eval(), something like this: $formAsString = $controller->command("readFileAndReturnString",...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.