Re:Parse error: syntax error, unexpected T_GLOBAL (1 viewing) (1) Guest
Favoured: 0
|
|
|
TOPIC: Re:Parse error: syntax error, unexpected T_GLOBAL
|
|
|
|
Parse error: syntax error, unexpected T_GLOBAL 4 Years, 8 Months ago
|
Karma: -1
|
|
I'm totally new to DirectPHP, that I'm trying to use in my Joomla 1.5 website (www.cascinesanpietro.it).
Website it's just starting, still with lot of example joomla contents.
When I try the code:
<?php
function f1() {
global $a;
return $a*2;
}
$b = f1($a);
?>
You can access variable $a from within the function with global.
variable $b = <?php echo $b;?>
I get the error message:
Parse error: syntax error, unexpected T_GLOBAL in /web/htdocs/www.cascinesanpietro.it/home/plugins/content/DirectPHP.php(49) : eval()'d code on line 2
The plugin is enabled, and its order is 2 (not 0).
It seems to work, a little, when I use your example code:
Now is: <?php echo date('Y-m-d H: i: s');?>
(added space after ":" to avoid emoticons)
but I had to add a question mark "?" after "<", before keyword "php". WHy didn't you put it? I'm asking it because I'm always afraid to lose some bit of information.
Thank you for your valuable work.
Greetings from Italy
Salvatore
|
|
|
|
|
|
|
Last Edit: 2008/10/11 18:55 By salrandazzo.
Reason: corrected mistake english language
|
|
|
The administrator has disabled public write access.
|
kksou (Admin)
Admin
Posts: 1680
|
|
Re:Parse error: syntax error, unexpected T_GLOBAL 4 Years, 8 Months ago
|
Karma: 27
|
Hi Salvatore,
Those are typos. DirectPHP uses the standard php syntax i.e. a question mark "?" after "<", before keyword "php. I've fixed all those typos in:
http://www.kksou.com/php-gtk2/Joomla/DirectPHP-plugin.php
I went to your site: www.cascinesanpietro.it. Those error messages are typed in by you. Can you please put back your PHP code and let me see the exact thing as reflected by DirectPHP.
Regards,
/kksou
|
|
|
|
|
|
|
Last Edit: 2008/10/11 19:50 By kksou.
|
|
|
The administrator has disabled public write access.
|
|
|
|
Re:Parse error: syntax error, unexpected T_GLOBAL 4 Years, 8 Months ago
|
Karma: -1
|
|
Hi Kksou, thank you so much about your FLASH answer!
I cleaned the situation. Now there is only the first comment line, and everything else is php code and system error message.
Thank you again!
Salvatore
|
|
|
|
|
|
|
The administrator has disabled public write access.
|
kksou (Admin)
Admin
Posts: 1680
|
|
Re:Parse error: syntax error, unexpected T_GLOBAL 4 Years, 8 Months ago
|
Karma: 27
|
|
Hi Salvatore,
Have relooked at your site. Need a bit more clues:
1. May I know when did you download the DirectPHP? Recently? Or sometime ago?
2. Are you using PHP4 or PHP5?
3. Can you copy and paste again here the code you have used that produce the error.
Regards,
/kksou
|
|
|
|
|
|
|
Last Edit: 2008/10/11 21:29 By kksou.
|
|
|
The administrator has disabled public write access.
|
kksou (Admin)
Admin
Posts: 1680
|
|
Re:Parse error: syntax error, unexpected T_GLOBAL 4 Years, 8 Months ago
|
Karma: 27
|
Hi Salvatore,
Please try one more thing. I assume you're using the latest version of DirectPHP:
1. Go to the folder plugins/content
2. Edit the file "DirectPHP.php" in your favorite editor.
3. Goto line 46 and add the line
| Code: |
echo "phpcode2 = ".htmlentities($phpcode2)."<br>";
|
so that it looks like:
| Code: |
$output .= $matches[1];
$phpcode = $matches[2];
$phpcode2 = $this->fix_str2($phpcode);
echo "phpcode2 = ".htmlentities($phpcode2)."<br>"; // add this line
global $errmsg;
if ($this->check_php($phpcode)) {
|
4. Now reload the page again. You should see the "real" PHP code that are being evaluated by DirectPHP. It will allow us to see what's really happening "behind the scene".
Regards,
/kksou
|
|
|
|
|
|
|
Last Edit: 2008/10/11 21:28 By kksou.
|
|
|
The administrator has disabled public write access.
|
|
|
|
Re:Parse error: syntax error, unexpected T_GLOBAL 4 Years, 8 Months ago
|
Karma: -1
|
|
Hi Kksou!
This is the Joomla! system info:
PHP created on: Linux webxc07s01.ad.aruba.it 2.6.18-92.1.10.el5PAE #1 SMP Tue Aug 5 08:14:05 EDT 2008 i686
Database version: 5.0.66a-log
Collation Database: utf8_general_ci
PHP Version: 4.4.7
Web Server: Apache/2.2
PHP Interface web server: cgi
Joomla! version: Joomla! 1.5.7 Production/Stable [ Wovusani ] 9-September-2008 23:00 GMT
User Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; it; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3i Kksou!
This is the Joomla! system info:
PHP created on: Linux webxc07s01.ad.aruba.it 2.6.18-92.1.10.el5PAE #1 SMP Tue Aug 5 08:14:05 EDT 2008 i686
Database version: 5.0.66a-log
Collation Database: utf8_general_ci
PHP Version: 4.4.7
Web Server: Apache/2.2
PHP Interface web server: cgi
Joomla! version: Joomla! 1.5.7 Production/Stable [ Wovusani ] 9-September-2008 23:00 GMT
User Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; it; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3
this is the code:
<?php global $a;
$a = 10;?>
This is a test. variable $a = <?php echo $a;?>
<?php
function f1() {
global $a;
return $a*2;
}
$b = f1($a);
?>
You can access variable $a from within the function with global.
variable $b = <?php echo $b;?>
Hope this can help you.
Thank you.
Salvo
|
|
|
|
|
|
|
Last Edit: 2008/10/11 21:39 By salrandazzo.
|
|
|
The administrator has disabled public write access.
|
kksou (Admin)
Admin
Posts: 1680
|
|
Re:Parse error: syntax error, unexpected T_GLOBAL 4 Years, 8 Months ago
|
Karma: 27
|
Hi Salvatore,
Thanks for the detailed info.
You're using PHP4!
You must have downloaded the version of DirectPHP quite some time ago.
The previous version of DirectPHP doesn't work with PHP4. I've updated the code quite some time ago so that it works with PHP4.
Please download the latest version of DirectPHP from
http://www.kksou.com/php-gtk2/Joomla/DirectPHP-plugin.php
and see if it works on your site.
Regards,
/kksou
|
|
|
|
|
|
|
Last Edit: 2008/10/11 21:35 By kksou.
|
|
|
The administrator has disabled public write access.
|
|
|
|
Re:Parse error: syntax error, unexpected T_GLOBAL 4 Years, 8 Months ago
|
Karma: -1
|
Sorry about it, KKsou, I forgot to answer this specific quesiton. But I downloaded DirectPHP just today!
File name is DirectPHP_v1.54.zip.
Readme file states:
Author: kksou
Email: support@kksou.com
Published: March 24, 2008
Version: 1.0
I'm afraid that we still didn't pinpoint the reason of the error... :-)
Salvo
|
|
|
|
|
|
|
The administrator has disabled public write access.
|
kksou (Admin)
Admin
Posts: 1680
|
|
Re:Parse error: syntax error, unexpected T_GLOBAL 4 Years, 8 Months ago
|
Karma: 27
|
Hi Salvatore,
In that case, please add the line:
| Code: | echo "phpcode2 = ".htmlentities($phpcode2)."<br>";
|
as mentioned above.
It will allow us to see the actual PHP code that is being processed.
Regards,
/kksou
|
|
|
|
|
|
|
Last Edit: 2008/10/11 23:14 By kksou.
|
|
|
The administrator has disabled public write access.
|
|
|
|
Re:Parse error: syntax error, unexpected T_GLOBAL 4 Years, 8 Months ago
|
Karma: -1
|
|
Ok Kksou, I did it and this is the result:
phpcode2 = global $a; $a = 10;
phpcode2 = echo $a;
phpcode2 = function f1() { Â Â Â global $a; Â Â Â return $a*2; } $b = f1($a);
phpcode2 = echo $b;
as you can see looking at the website.
This "Â Â Â" sounds not very nice. Something about char generator?
Salvo
|
|
|
|
|
|
|
Last Edit: 2008/10/11 23:06 By salrandazzo.
|
|
|
The administrator has disabled public write access.
|
|
|
|
|