Php parse error

Fermé
agent1266 - 2 avril 2011 à 20:22
 agent1266 - 3 avril 2011 à 15:34
Bonjour,

J'ai besoin d'un coup de main:

Parse error: syntax error, unexpected T_VARIABLE in /x/x/x/xxxxxxx.php on line 4

voici le code:

<?php

require_once('xxxxx.php');
$privatekey = "xxxx";
$resp = xxxxxxx_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["xxxxxxx_challenge_field"],
$_POST["xxxxxxx_response_field"]);

...

Merci


6 réponses

Bilow Messages postés 1022 Date d'inscription samedi 21 août 2010 Statut Membre Dernière intervention 2 août 2015 117
2 avril 2011 à 20:29
$resp = xxxxxxx_check_answer ($privatekey,

Et la fin de cette ligne elle est où ???

:-)
0
@Bilow:

il n'est pas là?:

$_POST["xxxxxxx_response_field"]);

sinon, j'ai copié le code sur le site de support officiel de google-recaptcha, et selon eux, il est correct. Et pour eux, c'est tout car ils ne s'occupent pas de la programmation.

Vous le savez maintenant, j'ai pas (encore) des compétences en php à ce niveau là.

...
0
Bilow Messages postés 1022 Date d'inscription samedi 21 août 2010 Statut Membre Dernière intervention 2 août 2015 117
3 avril 2011 à 10:32
Oups... Désolé :/

Je viens de tester ton code, il est correct.
Tout d'abord, vide le cache de ton navigateur (ou utilise une fois un autre), et vérifie si tu as toujours l'erreur.
Ensuite, ajoute après le <?php cette ligne-ci :
error_reporting(E_ALL);
Cela affichera toutes les erreurs possibles dans ton code.

Pour finir, envoi ici le contenu de xxxxx.php , on ne sait jamais.
Ah oui, essaie aussi d'appeler ta fonction avec des espaces, sans retour à la ligne.

Bye ;)
0
Bjour Bilow et les autres,

j'ai fait que vous m'avez demandé, mais rien ci fait. Est-ce que ça peut être un problème chez l'hebergeur, genre mauvaise positions des fichiers, ou pas d'acces depuis mon espace?

maintenant il me donne une erreur en ligne 2:

Parse error: syntax error, unexpected T_STRING in /x/x/x/contact-goa.php on line 2

et voici tout le code:


1 <?php
2 error_reporting(E_ALL);
3 require_once('recaptchalib.php');
4 $privatekey = "x";
5 $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
6
7 if (!$resp->is_valid) {
8 // What happens when the CAPTCHA was entered incorrectly
9 die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." .
10 "(reCAPTCHA said: " . $resp->error . ")");
11 } else {
12
13 $notindomain_errorpage = "error.html";
14 $server_errorpage = "error.html";
15 $invalidaddress_errorpage = "error.html";
16 $successpage = "succes.html";
17 $recipient="x@x.x";
18 $subject="Web site feedback";
19
20 // Set the server variables for older (PHP4,3 etc) systems
21 if (!isset($_SERVER)){
22 $_POST = &$HTTP_POST_VARS;
23 $_SERVER = &$HTTP_SERVER_VARS;
24 }
25
26
27 $servername = $_SERVER['SERVER_NAME'];
28
29 if ($_SERVER['REQUEST_METHOD']=="POST") {
30 if (strpos($_SERVER['HTTP_REFERER'], $_SERVER['HTTP_HOST'])>7 || !strpos($_SERVER['HTTP_REFERER'], $_SERVER['HTTP_HOST'])) {
31 header( "Location: ".$notindomain_errorpage );
32 exit;
33 } else {
34 $msg="The following information was submitted from a form on ".$servername.":\n\n";
35
36 foreach($_POST as $key => $val) {
37 //filter out any form items called send or reset
38 //image based submit and reset buttons will be in the format
39 // send_x: 13
40 // send_y: 10
41
42 $myKeySlice = substr("$key",0,4);
43 if ($myKeySlice != "send" && $myKeySlice != "rese"){
44
45
46 //The honey trap for spam bots. If it contains data then send them packing
47 if ($key == "comments_72146" && $val != ""){
48 header( "Location: ".$successpage."#" );
49 exit;
50 }
51
52 if ($key == "subject" || $key == "email" || $key == "name"){
53 //Prevent injection attacks by stripping tags and newlines from the data
54 //Do this only on data that makes it into the e-mail header as newlines in a message body should still be valid
55 $key = strip_tags($key);
56 $val = strip_tags($val);
57 if (eregi("\r",$key) || eregi("\n",$key)){
58 header( "Location: ".$notindomain_errorpage );
59 exit;
60 }
61 if (eregi("\r",$val) || eregi("\n",$val)){
62 header( "Location: ".$notindomain_errorpage );
63 exit;
64 }
65 }
66
67 if ($key != "comments_72146"){
68 //replace any underscores in the input names (PHP puts these in!) with spaces
69 $key = str_replace("_"," ",$key);
70
71 //if the form item is called "subject" then set this as the subject line of the mail
72 if ($key == "subject"){
73 $subject=$val;
74 } else {
75 if (is_array($val)){
76 $msg.="Item: $key\n";
77 foreach($val as $v)
78 $msg.=" $v\n";
79 } else {
80 $msg.="$key: $val\n";
81 }
82 }
83 }
84 }
85 }
86
87
88 $ip=@$REMOTE_ADDR;
89 $msg.="IP address=".$ip."\n";
90
91
92 //set up the default headers
93 $headers = "";
94
95 //get the senders name (if specified)
96 if ($_POST["name"]) {
97 $name = $_POST["name"];
98 } else {
99 $name = "";
100 }
101
102 //get the senders email address (if specified)
103 if (isset($_POST["email"])) {
104 $email = $_POST["email"];
105 if (!preg_match('/^[a-zA-Z0-9_\.-]+@[a-zA-Z0-9-\.]+\.[a-zA-Z]+(\.[a-zA-Z]+)?$/', $email)){
106 header( "Location: ".$invalidaddress_errorpage );
107 exit;
108 }
109 } else {
110
111 //the email is missing!
112 //strip the domain from the address
113 //www.domain.com -> domain.com
114 if (substr($servername,0,4) == "www."){
115 $theaddress = substr($theaddress,4);
116 }
117 $email = "noreply@".$theaddress;
118 $msg.="\n\n------------------------------------------------------------------";
119 $msg.="\nPLEASE NOTE: This is a message from the ".$servername." web site";
120 $msg.="\nand has been sent from a machine and not a person.";
121 $msg.="\nPlease do not reply to this e-mail as it will bounce.";
122 $msg.="\n------------------------------------------------------------------";
123
124
125 }
126
127 $headers .= "From: $name <$email>\r\n";
128
129 //add the correct headers for plain text
130 //see: http://www.webmasterworld.com/php/3949990.htm
131 $headers .= "MIME-Version: 1.0\n";
132 $headers .= "Content-type: text/plain; charset=\"ISO-8859-1\"\n";
133 $headers .= "Content-transfer-encoding: 7bit\n";
134
135 $headers .= "Reply-To: $email\r\n"."Return-Path: $email";
136
137
138 error_reporting(0);
139 if (mail($recipient, $subject, $msg, $headers)){//
140 header( "Location: ".$successpage );
141 } else {
142 header( "Location: ".$server_errorpage );
143 }
144 }
145 } else {
146 header( "Location: ".$server_errorpage );
147 }
148 }
149 ?>
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
Bilow Messages postés 1022 Date d'inscription samedi 21 août 2010 Statut Membre Dernière intervention 2 août 2015 117
3 avril 2011 à 13:34
Alors là, je ne sais vraiment pas t'aider...
Quel est ton hébergeur ?
Le fichier que tu viens d'envoyer, c'est contact-goa.php ?
Il signale une erreur dans la ligne deux, juste celle que je t'ai dit d'ajouter. Commente cette ligne ou supprime-la, et réessaie ton code.

Quelle est ta version de PHP ? Pour le savoir ecrit phpinfo() dans une page php.
A part un problème de chez l'hébergeur, je ne vois pas d'autre explication. Et même si c'était chez l'hébergeur, je ne comprendrais pas. Contacte-le, c'est peut-être ta seule chance :/
0
merci bien pour m'aider avec mes soucis,
merdi avec les captchas.

merci
0