OVH Community, votre nouvel espace communautaire.

[PHP] Parse error: syntax error, unexpected '{'


Nowwhat
09/12/2012, 00h50
Bascule le mode de transfert de FileZilla en 'bin' et ça va aller mieux

Alpham
08/12/2012, 20h47
Voilà, j'ai trouvé la solution donc je viens la partager :

En réalité il s'agit apparemment d'un problème rencontré lorsque l'on importe des fichiers depuis FileZilla, lequel aurait tendance à endommager les fichiers qu'il fait transiter.

Solutions :

  • Utiliser un autre client
  • Importer le thème via Wordpress sous format .zip


Merci à ceux qui m'ont donné un coup de main

Alpham
07/12/2012, 22h31
Merci pour ton aide Nowhat

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, postmaster@cassandrelaurent.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.
Ca me semble mal parti...

Nowwhat
05/12/2012, 22h41
Citation Envoyé par Alpham
2. Comment "appeler" un fichier ?
http://www.ton-domaine.tld/test.php

Alpham
05/12/2012, 20h00
Merci pour vos réponses

1. J'ai supprimé l'extension et le fichier est maintenant nommé ".htaccess" (reconnu en tant que fichier HTACCESS sur FileZilla).

2. Comment "appeler" un fichier ?

Nowwhat
05/12/2012, 18h00
Sinon, fabrique un fichier nommé test.php dans le /www/ avec ceci à l'intérieur:
Code PHP:
 phpinfo();
?>
puis appelle le.

RobertG
05/12/2012, 17h55
Citation Envoyé par Alpham
Merci pour ta réponse Alex.P.

J'ai placé le .htaccess à la racine et dans le /www mais rien ne change...

Le fichier ne contient que "SetEnv PHP_VER 5_4" et j'en ai bien supprimé l'extension .txt une fois sur mon FTP.

Quel pourrait-être le problème ?

Merci
Si tu t'es contenté de supprimer ".txt", le fichier s'appelle donc "htaccess" et pas ".htaccess"

Alpham
05/12/2012, 17h38
Voila le .php en question :

add_action( 'admin_init', 'backgroundmenuregs' );
add_action( 'wp_head', 'add_bg_changerstyle' );
function backgroundmenuregs(){
wp_enqueue_script('jquery');
wp_register_style( 'FlowTypographyMainStylesheet', WP_PLUGIN_URL . '/typography/js/colorpicker/css/colorpicker.css' );
wp_register_style( 'FlowTypographyLayoutStylesheet', WP_PLUGIN_URL . '/typography/js/colorpicker/css/layout.css' );
wp_register_script('jquery_colorpicker_script', WP_PLUGIN_URL . '/typography/js/colorpicker/js/colorpicker.js', array('jquery'), '1.0' );
wp_enqueue_style( 'FlowTypographyMainStylesheet' );
wp_enqueue_style( 'FlowTypographyLayoutStylesheet' );
wp_enqueue_script('jquery_colorpicker_script');
}
function add_bg_menu(){
//must check that the user has the required capability
if (!current_user_can('manage_options'))
{
wp_die( __('You do not have sufficient permissions to access this page.') );
}

echo '
';
echo "

" . __( 'Styling', 'menu-test' ) . "

";

if($_POST['bg_submit_h'] && $_POST['bg_submit_h'] == "Y"){
$bgrepeat = array("repeat"=>"repeat","repeatx"=>"repeat-x","repeaty"=>"repeat-y","norepeat"=>"no-repeat");
update_option("bgchanger_color", $_POST['bc']);
update_option("bgchanger_imgsrc", $_POST['bi']);
if($_POST['bpx'] == "left" || $_POST['bpx'] == "center" || $_POST['bpx'] == "right"){
update_option("bgchanger_posx", $_POST['bpx']);
}
if($_POST['bpy'] == "top" || $_POST['bpy'] == "center" || $_POST['bpy'] == "bottom"){
update_option("bgchanger_posy", $_POST['bpy']);
}
if($_POST['ba'] == "fixed" || $_POST['ba'] == "scroll"){
update_option("bgchanger_attach", $_POST['ba']);
}
if(array_key_exists($_POST['br'], $bgrepeat)){
update_option("bgchanger_repeat", $bgrepeat[$_POST['br']]);
}
?>


}

$bgcval_bc = get_option("bgchanger_color");
$bgcval_bi = get_option("bgchanger_imgsrc");
$bgcval_bpx = get_option("bgchanger_posx");
$bgcval_bpy = get_option("bgchanger_posy");
$bgcval_ba = get_option("bgchanger_attach");
$bgcval_br = get_option("bgchanger_repeat");
?>









Background color
>

Background imageUpload
Background position
Background attachment
Background repeat









}

function add_bg_changerstyle(){
$bgcval_bc = get_option("bgchanger_color");
$bgcval_bi = get_option("bgchanger_imgsrc");
if($bgcval_bc || $bgcval_bi){
print("");
}
}

?>

Alpham
03/12/2012, 18h09
Merci pour ta réponse Alex.P.

J'ai placé le .htaccess à la racine et dans le /www mais rien ne change...

Le fichier ne contient que "SetEnv PHP_VER 5_4" et j'en ai bien supprimé l'extension .txt une fois sur mon FTP.

Quel pourrait-être le problème ?

Merci

Alex.P
03/12/2012, 18h02
Place ton .htaccess à la racine de ton site ( ou dossier www/ ) afin que php5_4 soit appliqué sur l'ensemble de ton site !

Alex.P

Alpham
02/12/2012, 22h33
Bonjour,

Voici mon erreur :

Parse error: syntax error, unexpected '}' in /homez.582/cassandrf/www/Alpham/wp-content/themes/daisho/framework/admin/background-menu.php on line 1

Ce que j'ai fait :

Créé un fichier .htaccess (contenu : SetEnv PHP_VER 5_4)
Le placé sur mon FTP (dans www/Alpham où se trouve le thème)

Rien ne change. Quoi faire ?

Merci !

Pistach3
05/03/2011, 08h40
C'est parfait !

Merci beaucoup de ton aide,

Bon dimanche

Sébastien Ferry
05/03/2011, 03h03
À priori, ton PHP n'apprécie pas les exceptions ( try { ... } , ligne 12).

http://www.php.net/manual/en/language.exceptions.php (la version française ne précise pas PHP5)

PHP 5 has an exception model similar to that of other programming languages. An exception can be thrown, and caught ("catched") within PHP. Code may be surrounded in a try block, to facilitate the catching of potential exceptions.

Donc, passe en PHP 5: http://guides.ovh.com/Php5ChezOvh (ou 6... http://guides.ovh.com/PhpChezOvh) avec une ligne supplémentaire dans un fichier .htaccess (exemple pour PHP 5.2):
Code:
SetEnv PHP_VER 5

Pistach3
04/03/2011, 22h45
Salutation,

J'ai actuellement un problème, je suis entrain de coder ma page coming soon, que j'ai testé et qui marche à merveille en local sous wamp, mais lorsque j'upload sur le ftp, j'ai comme erreur:
Parse error: syntax error, unexpected '{' in /homez.314/jaimemat/www/index.php on line 12
Le code PHP de l'index.php en question:

Code PHP:

require "includes/connect.php";

$msg '';

if(
$_POST['email']){
    
    
// Requested with AJAX:
    
$ajax = ($_SERVER['HTTP_X_REQUESTED_WITH']  == 'XMLHttpRequest');
    
    try{
        if(!
filter_input(INPUT_POST,'email',FILTER_VALIDATE_EMAIL)){
            throw new 
Exception('Mail invalide.. ');
        }

        
$mysqli->query("INSERT INTO coming_soon_emails
                        SET email='"
.$mysqli->real_escape_string($_POST['email'])."'");
        
        if(
$mysqli->affected_rows != 1){
            throw new 
Exception('Cet email existe déjà.');
        }
        
        if(
$ajax){
            die(
'{"status":1}');
        }
        
        
$msg "Merci :D et à bientôt !";
        
    }
    catch (
Exception $e){
        
        if(
$ajax){
            die(
json_encode(array('error'=>$e->getMessage())));
        }
        
        
$msg $e->getMessage();        
    }
}
?>
Le code PHP du connect.php en question:
Code PHP:

error_reporting
(E_ALL E_NOTICE);

$db_host 'localhost';
$db_user 'root';
$db_pass '';
$db_name '';

@
$mysqli = new mysqli($db_host$db_user$db_pass$db_name);

if (
mysqli_connect_errno()) {
    die(
'

Connexion base de donnée impossible :( 

'
);
}

$mysqli->set_charset("utf8");


?>
Merci d'avance pour votre aide !