473,831 Members | 2,092 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Parse Error - Unexpected T_OBJECT_OPERAT OR

4 New Member
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 14013
Atli
5,058 Recognized Expert Expert
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
devereaux
4 New Member
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_functi ons.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
devereaux
4 New Member
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
devereaux
4 New Member
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 Recognized Expert Expert
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
51399
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 class class Session { // Define the properties:
3
15064
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> </head> <style type="text/css">
6
19035
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 submitting user information into my creation script, I get the following error from the page that is suppose to insert the user data into the database, create a code, then send an email out for verification. Parse error: parse error, unexpected $end in...
8
46201
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 where the inital " started? I find myself adding /* */ blocks or cutting/pasting sections of code out in order to find where the error occured. Wouldn't it it be nice if the warning message included the line in teh source where the initial quote ...
5
13179
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') VALUES ('$_POST', '$_POST', '$_POST') mysql_query($sql)"; When I view the code in Internet Explorer I get the following error message: Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or...
1
6847
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 3. drop_table :users 4. 5. create_table :users, :options => 'ENGINE=InnoDB DEFAULT CHARSET=utf8' do |t| 6. t.column :first_name, :string
1
2336
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 script, but if i disable an if statement (code below) then my code functions correctly... if($specs == "DT") { $angle = $specs; $rating = $specs; if($angle == "00" || $angle == "30")
3
1341
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 /home/www/zammarket.freehostia.com/signup.php on line 22 Line 22 is the last line in the file. My code is here: <?php echo "Starting..."; @mysql_connect(My_Sql_Server, My_DB, My_Password) or die("Cannot Connect To DB!"); @mysql_select_db(My_DB) or die("Cannot...
2
3232
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", $formName); // 06-22-07 - the next commands try to import all the functions that the
0
10778
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10496
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10538
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10210
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6951
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5622
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5788
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4419
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3967
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.