Announcement

#1 2020-07-27 23:11:11

farmeron
Member
2020-07-27
3

Parse error: syntax error

Greetings,

I am working on making the custom changes in article: https://piwigo.org/doc/doku.php?id=user … last_names

I changed the content of register.tpl and indentification.tpl in /themes/default/template directory.

I then used LocalFiles Editor to paste the content into Personal Plugin below (between */ and ?>):
- - - - - - - - - -
<?php
/*
Plugin Name: Personal Plugin
Version: 1.0
Description: Personal Plugin
Plugin URI: http://piwigo.org
Author:
Author URI:
*/

add_event_handler('init', 'id_fam');
function id_fam(){
  global $template, $user;
  $template->assign(array(    'F_KEY' => get_ephemeral_key(6)  ));

  if (isset($_POST['firstname']) and isset($_POST['lastname']))
  {
    $_POST['login']=ucwords(strtolower(strip_tags($_POST['firstname']))).' '.ucwords(strtolower(strip_tags($_POST['lastname'])));
    $_POST['username']=ucwords(strtolower(strip_tags(($_POST['firstname']))).' '.ucwords(strtolower(strip_tags(($_POST['lastname'])));
    $template->assign(array(      'F_LASTNAME' => $_POST['lastname'],      'F_FIRSTNAME' => $_POST['firstname']    ));
  }
}


?>
- - - - - - - - - -
When I save the file, I receive the error message:
Parse error: syntax error, unexpected ';', expecting ')' in /home/epnet29info/public_html/pwg/plugins/LocalFilesEditor/include/functions.inc.php(45) : eval()'d code on line 19

I tried removing the semicolon from what I think is line 19 (begjns $_POST['username']). Also adding another close parenthesis both with and without the semicolon, but I still receive similar error messages.

Any suggestions?
Ron

Piwigo version: 2.10.2
PHP version: 7.4.8
MySQL version: 10.2.32-MariaDB
Piwigo URL: http://equinephotographers.info/pwg/

Offline

 

#2 2020-07-27 23:49:13

erAck
Only trying to help
2015-09-06
2027

Re: Parse error: syntax error

Please post code as code blocks (see here) so we can see the actual code and not what appears to be arbitrarily line-wrapped.

My assumption: you copy-pasted the code already line-wrapped without knowing what it is supposed to do. The newlines before the '.ucwords(... should actually be spaces instead.


Running Piwigo at https://erack.net/gallery/

Offline

 

#3 2020-07-28 00:03:34

farmeron
Member
2020-07-27
3

Re: Parse error: syntax error

Sorry about that. Let me try again. This is the full Personal Plugin text:

Code:

<?php
/*
Plugin Name: Personal Plugin
Version: 1.0
Description: Personal Plugin
Plugin URI: http://piwigo.org
Author:
Author URI:
*/

add_event_handler('init', 'id_fam');
function id_fam(){
  global $template, $user;
  $template->assign(array(    'F_KEY' => get_ephemeral_key(6)  ));
 
  if (isset($_POST['firstname']) and isset($_POST['lastname']))
  {
    $_POST['login']=ucwords(strtolower(strip_tags($_POST['firstname']))).' '.ucwords(strtolower(strip_tags($_POST['lastname'])));
    $_POST['username']=ucwords(strtolower(strip_tags(($_POST['firstname']))).' '.ucwords(strtolower(strip_tags(($_POST['lastname'])));
    $template->assign(array(      'F_LASTNAME' => $_POST['lastname'],      'F_FIRSTNAME' => $_POST['firstname']    ));
  } 
}


?>

Which is what it looks like in LocalFiles Editor as well as the documentation. And you are correct. I know what it is supposed to do in concept and can generally see the function but do not know the coding technique - not sure what all the parentheses do and why they are not paired. Willing to learn though.

Offline

 

#4 2020-07-28 00:08:56

erAck
Only trying to help
2015-09-06
2027

Re: Parse error: syntax error

This line

Code:

    $_POST['username']=ucwords(strtolower(strip_tags(($_POST['firstname']))).' '.ucwords(strtolower(strip_tags(($_POST['lastname'])));

should be

Code:

    $_POST['username']=ucwords(strtolower(strip_tags($_POST['firstname']))).' '.ucwords(strtolower(strip_tags($_POST['lastname'])));

instead (note the erroneous extra '(' parentheses in front of both $_POST).

And yes, it's already wrong in the documentation.


Running Piwigo at https://erack.net/gallery/

Offline

 

#5 2020-07-28 00:28:37

farmeron
Member
2020-07-27
3

Re: Parse error: syntax error

Thank you erAck, "File written successfully."

I should have compared the two lines and noted the issue but was too busy looking for an errant semicolon.

Your help is most appreciated!
Ron

Offline

 

Board footer

Powered by FluxBB

github twitter newsletter Donate Piwigo.org © 2002-2024 · Contact