error de análisis?

  • mindfullsilence
  • Professor
  • Professor
  • Avatar de Usuario
  • Registrado: Ago 04, 2008
  • Mensajes: 846
  • Status: Offline

Nota Julio 1st, 2009, 7:03 pm

Estoy recibiendo este error en un script PHP & #058;
Código: [ Select ]
Parse error: parse error in C:\USR\bin\wamp\dir\example.php on line 11


Esta es la línea 11:
Código: [ Select ]
$mail_prefix = 'A quote request was sent to you from ' . $_POST['firstname'] . ' ' . $_POST['lastname'] . '\r\n <hr />';


Alguien sabe de qué se trata todo esto?
Use your words like arrows to shoot toward your goal.
  • Anonymous
  • Bot
  • No Avatar
  • Registrado: 25 Feb 2008
  • Mensajes: ?
  • Loc: Ozzuland
  • Status: Online

Nota Julio 1st, 2009, 7:03 pm

  • Bigwebmaster
  • Site Admin
  • Site Admin
  • Avatar de Usuario
  • Registrado: Dic 20, 2002
  • Mensajes: 8925
  • Loc: Seattle, WA & Phoenix, AZ
  • Status: Offline

Nota Julio 1st, 2009, 7:22 pm

¿Cuáles son algunas de las líneas que preceden a la línea que nos dio? Te has olvidado de cerrar todas las líneas con puntos y comas?

También esta parte:

Código: [ Select ]
'\r\n <hr />'


Estoy bastante seguro de que el \ r \ n (las secuencias de escape) no se interpreta correctamente a menos que poner entre comillas dobles:

Código: [ Select ]
"\r\n <hr />"


Como se muestra aquí:

http://www.php.net/manual/en/language.t ... tax.double

A pesar de que todavía no deben traducirse en su código de error de análisis.
Ozzu Hosting - Want your website on a fast server like Ozzu?
  • mindfullsilence
  • Professor
  • Professor
  • Avatar de Usuario
  • Registrado: Ago 04, 2008
  • Mensajes: 846
  • Status: Offline

Nota Julio 1st, 2009, 7:41 pm

wow, eso fue bastante simple. Didnt tiene un punto y coma en la línea anterior.
Use your words like arrows to shoot toward your goal.
  • mindfullsilence
  • Professor
  • Professor
  • Avatar de Usuario
  • Registrado: Ago 04, 2008
  • Mensajes: 846
  • Status: Offline

Nota Julio 1st, 2009, 8:02 pm

no, espera...sigue recibiendo el error
Use your words like arrows to shoot toward your goal.
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • Avatar de Usuario
  • Registrado: Dic 20, 2002
  • Mensajes: 8925
  • Loc: Seattle, WA & Phoenix, AZ
  • Status: Offline

Nota Julio 1st, 2009, 8:13 pm

Si sigues teniendo el error nos puede mostrar el código por todas partes esa línea? ¿Es el mismo error?
Ozzu Hosting - Want your website on a fast server like Ozzu?
  • mindfullsilence
  • Professor
  • Professor
  • Avatar de Usuario
  • Registrado: Ago 04, 2008
  • Mensajes: 846
  • Status: Offline

Nota Julio 1st, 2009, 8:13 pm

Código: [ Select ]
 
<?php
/* Some required variables to configure this page */
include("../../bin/php/php5.2.9-2/PEAR/Structures/Mail.php");
// Variables not to be sent to you
$blocked = array('submit1');
 
// The email address the result of the form would be sent to.
$adm_email = 'your_email@your_host.com';
 
// The prefix to the mail
$mail_prefix = 'A quote request for selection' . $_POST['service'] . ' was sent to you from ' . $_POST['firstname'] . ' ' . $_POST['lastname'] . "\r\n" . ' <hr />';
 
// The post (signature) to the mail
$mail_post = null;
 
// The title for the message
$title = 'A ' . $_POST['service'] . ' request was sent to you from ' . $_POST['firstname'] . ' ' . $_POST['lastname'];
 
/* The actual code body for sending */
 
// Initiating the body var
$body = $mail_prefix;
 
// Initiating some numeric values that would be incremented in the following loop
$blocked_num = 0;
 
// Building the body for the mail
foreach($_POST as $field_name => $field_value)
{
    // Building the body for the mail with the correct fields
    if($field_name != $blocked[$blocked_num])
        $body .= "<strong>{$field_name}</strong>: {$_POST[$field_name]}<br />\r\n";
 
    // Initiating the blocked num counter if needed
    if(count($blocked) < $blocked_num)
        ++$blocked_num;
}
 
// Ending the body var
$body .= $mail_post;
 
// Trimming the ends of body from any unneeded white spaces
$body = trim($body);
 
// Requiring the SMTP class
require_once 'mail.php';
 
// Initiating the mail object
$mail = new mail();
 
// Sending the message
if(new mail($_POST['email'], $title, $body, true))
    echo 'The mail was successfully sent. Thank you for your time!';
else
    echo 'There was an error in the mailling service.';
?>
 
  1.  
  2. <?php
  3. /* Some required variables to configure this page */
  4. include("../../bin/php/php5.2.9-2/PEAR/Structures/Mail.php");
  5. // Variables not to be sent to you
  6. $blocked = array('submit1');
  7.  
  8. // The email address the result of the form would be sent to.
  9. $adm_email = 'your_email@your_host.com';
  10.  
  11. // The prefix to the mail
  12. $mail_prefix = 'A quote request for selection' . $_POST['service'] . ' was sent to you from ' . $_POST['firstname'] . ' ' . $_POST['lastname'] . "\r\n" . ' <hr />';
  13.  
  14. // The post (signature) to the mail
  15. $mail_post = null;
  16.  
  17. // The title for the message
  18. $title = 'A ' . $_POST['service'] . ' request was sent to you from ' . $_POST['firstname'] . ' ' . $_POST['lastname'];
  19.  
  20. /* The actual code body for sending */
  21.  
  22. // Initiating the body var
  23. $body = $mail_prefix;
  24.  
  25. // Initiating some numeric values that would be incremented in the following loop
  26. $blocked_num = 0;
  27.  
  28. // Building the body for the mail
  29. foreach($_POST as $field_name => $field_value)
  30. {
  31.     // Building the body for the mail with the correct fields
  32.     if($field_name != $blocked[$blocked_num])
  33.         $body .= "<strong>{$field_name}</strong>: {$_POST[$field_name]}<br />\r\n";
  34.  
  35.     // Initiating the blocked num counter if needed
  36.     if(count($blocked) < $blocked_num)
  37.         ++$blocked_num;
  38. }
  39.  
  40. // Ending the body var
  41. $body .= $mail_post;
  42.  
  43. // Trimming the ends of body from any unneeded white spaces
  44. $body = trim($body);
  45.  
  46. // Requiring the SMTP class
  47. require_once 'mail.php';
  48.  
  49. // Initiating the mail object
  50. $mail = new mail();
  51.  
  52. // Sending the message
  53. if(new mail($_POST['email'], $title, $body, true))
  54.     echo 'The mail was successfully sent. Thank you for your time!';
  55. else
  56.     echo 'There was an error in the mailling service.';
  57. ?>
  58.  


Heres el código HTML de la forma si es de relevancia:
Código: [ Select ]
<div id="form1" align="left">
<h2 align="center">Get A Quote!</h2>
<form id="form" action="sendemail.php" method="post">
<table width="90%" border="0" cellspacing="0" cellpadding="0">
<tr>
    <td>First Name:</td>
    <td><input type="text" name="firstname" size="51" /></td>
</tr>
<tr>
    <td>Last Name:</td>
    <td><input type="text" name="lastname" size="51" /></td>
</tr>
<tr>
    <td>Email Address:</td>
    <td><input type="text" name="email" size="51" /></td>
</tr>
<tr>
    <td>Service:</td>
    <td><select name="service" id="service">
     <option value="1">Website Design</option>
     <option value="2">Website Hosting</option>
     <option value="3">Email Hosting</option>
    </select></td>
</tr>
<tr>
    <td>Comments:</td>
    <td><textarea name="textarea" cols="54"></textarea></td>
</tr>
<tr>
    <td>&nbsp;</td>
    <td><div align="right">
     <input type="submit" name="submit1" id="submit1" value="Submit">
    </div></td>
</tr>
</table>
</form>
</div>
  1. <div id="form1" align="left">
  2. <h2 align="center">Get A Quote!</h2>
  3. <form id="form" action="sendemail.php" method="post">
  4. <table width="90%" border="0" cellspacing="0" cellpadding="0">
  5. <tr>
  6.     <td>First Name:</td>
  7.     <td><input type="text" name="firstname" size="51" /></td>
  8. </tr>
  9. <tr>
  10.     <td>Last Name:</td>
  11.     <td><input type="text" name="lastname" size="51" /></td>
  12. </tr>
  13. <tr>
  14.     <td>Email Address:</td>
  15.     <td><input type="text" name="email" size="51" /></td>
  16. </tr>
  17. <tr>
  18.     <td>Service:</td>
  19.     <td><select name="service" id="service">
  20.      <option value="1">Website Design</option>
  21.      <option value="2">Website Hosting</option>
  22.      <option value="3">Email Hosting</option>
  23.     </select></td>
  24. </tr>
  25. <tr>
  26.     <td>Comments:</td>
  27.     <td><textarea name="textarea" cols="54"></textarea></td>
  28. </tr>
  29. <tr>
  30.     <td>&nbsp;</td>
  31.     <td><div align="right">
  32.      <input type="submit" name="submit1" id="submit1" value="Submit">
  33.     </div></td>
  34. </tr>
  35. </table>
  36. </form>
  37. </div>
Use your words like arrows to shoot toward your goal.
  • Bogey
  • Bogey
  • Genius
  • Avatar de Usuario
  • Registrado: Jul 14, 2005
  • Mensajes: 8211
  • Loc: USA
  • Status: Offline

Nota Julio 1st, 2009, 8:37 pm

Intente lo siguiente...No sé si habría que corregir el error, pero yo sabía que iban a ahorrar un poco de poder de procesamiento (Im bastante seguro).
Código: [ Select ]
<?php
/* Some required variables to configure this page */

// Variables not to be sent to you
$blocked = array('submit1');

// The email address the result of the form would be sent to.
$adm_email = 'your_email@your_host.com';

// The prefix to the mail
$mail_prefix = "A quote request for selection ({$_POST['service']}) was sent to you from {$_POST['firstname']} {$_POST['lastname']}\r\n <hr />";

// The post (signature) to the mail
$mail_post = null;

// The title for the message
$title = "A {$_POST['service']} request was sent to you from {$_POST['firstname']} " . $_POST['lastname'];

/* The actual code body for sending */

// Initiating the body var
$body = $mail_prefix;

// Building the body for the mail with the correct fields
foreach($_POST as $field_name => $field_value)
    if(!in_array($field_name, $blocked))
        $body .= "<strong>{$field_name}</strong>: {$field_value}<br />\r\n";

// Ending the body var
$body .= $mail_post;

// Trimming the ends of body from any unneeded white spaces
$body = trim($body);

// Requiring the SMTP class
require_once 'mail.php';

// Initiating the mail object
$mail = new mail();

// Sending the message
if(new mail($_POST['email'], $title, $body, true))
    echo 'The mail was successfully sent. Thank you for your time!';
else
    echo 'There was an error in the mailling service.';
?>
  1. <?php
  2. /* Some required variables to configure this page */
  3. // Variables not to be sent to you
  4. $blocked = array('submit1');
  5. // The email address the result of the form would be sent to.
  6. $adm_email = 'your_email@your_host.com';
  7. // The prefix to the mail
  8. $mail_prefix = "A quote request for selection ({$_POST['service']}) was sent to you from {$_POST['firstname']} {$_POST['lastname']}\r\n <hr />";
  9. // The post (signature) to the mail
  10. $mail_post = null;
  11. // The title for the message
  12. $title = "A {$_POST['service']} request was sent to you from {$_POST['firstname']} " . $_POST['lastname'];
  13. /* The actual code body for sending */
  14. // Initiating the body var
  15. $body = $mail_prefix;
  16. // Building the body for the mail with the correct fields
  17. foreach($_POST as $field_name => $field_value)
  18.     if(!in_array($field_name, $blocked))
  19.         $body .= "<strong>{$field_name}</strong>: {$field_value}<br />\r\n";
  20. // Ending the body var
  21. $body .= $mail_post;
  22. // Trimming the ends of body from any unneeded white spaces
  23. $body = trim($body);
  24. // Requiring the SMTP class
  25. require_once 'mail.php';
  26. // Initiating the mail object
  27. $mail = new mail();
  28. // Sending the message
  29. if(new mail($_POST['email'], $title, $body, true))
  30.     echo 'The mail was successfully sent. Thank you for your time!';
  31. else
  32.     echo 'There was an error in the mailling service.';
  33. ?>


[EDIT:] He editado el código de arriba, me envió hace un rato. Yo lo he probado y funciona bien para mí...crea el cuerpo bien (Tenga en cuenta que lo que el nombre de su campo, que es lo que sus nombres de campo en el cuerpo se llama).
"Bring forth therefore fruits meet for repentance:" Matthew 3:8
  • mindfullsilence
  • Professor
  • Professor
  • Avatar de Usuario
  • Registrado: Ago 04, 2008
  • Mensajes: 846
  • Status: Offline

Nota Julio 1st, 2009, 9:49 pm

imponente. ¿Cómo puedo redireccionar a mi página de inicio si el correo enviado?
Use your words like arrows to shoot toward your goal.
  • Bogey
  • Bogey
  • Genius
  • Avatar de Usuario
  • Registrado: Jul 14, 2005
  • Mensajes: 8211
  • Loc: USA
  • Status: Offline

Nota Julio 1st, 2009, 10:02 pm

Cambiar
Código: [ Select ]
// Sending the message
if(new mail($_POST['email'], $title, $body, true))
    echo 'The mail was successfully sent. Thank you for your time!';
else
    echo 'There was an error in the mailing service.';
  1. // Sending the message
  2. if(new mail($_POST['email'], $title, $body, true))
  3.     echo 'The mail was successfully sent. Thank you for your time!';
  4. else
  5.     echo 'There was an error in the mailing service.';
para
Código: [ Select ]
// Sending the message
if(new mail($_POST['email'], $title, $body, true))
{
    echo 'The mail was successfully sent. Thank you for your time!';
    ob_flush();
    flush();
    sleep(5); // Sleep for 5 seconds before redirecting
    header("LOCATION: index.php");
}
else
    echo 'There was an error in the mailing service.';
  1. // Sending the message
  2. if(new mail($_POST['email'], $title, $body, true))
  3. {
  4.     echo 'The mail was successfully sent. Thank you for your time!';
  5.     ob_flush();
  6.     flush();
  7.     sleep(5); // Sleep for 5 seconds before redirecting
  8.     header("LOCATION: index.php");
  9. }
  10. else
  11.     echo 'There was an error in the mailing service.';
Trate de que...si no muestra el texto, a continuación, cambiar el orden de los dos flushs.
"Bring forth therefore fruits meet for repentance:" Matthew 3:8
  • mindfullsilence
  • Professor
  • Professor
  • Avatar de Usuario
  • Registrado: Ago 04, 2008
  • Mensajes: 846
  • Status: Offline

Nota Julio 1st, 2009, 11:32 pm

hmmm, eso es causa del problema:
Código: [ Select ]
Warning: Cannot modify header information - headers already sent by (output started at C:\USR\bin\wamp\www\voltec\sendemail.php:55) in C:\USR\bin\wamp\www\voltec\sendemail.php on line 58
Use your words like arrows to shoot toward your goal.
  • Bogey
  • Bogey
  • Genius
  • Avatar de Usuario
  • Registrado: Jul 14, 2005
  • Mensajes: 8211
  • Loc: USA
  • Status: Offline

Nota Julio 1st, 2009, 11:55 pm

Cambiar el texto siguiente:
Código: [ Select ]
header("LOCATION: index.php");
para
Código: [ Select ]
echo "<script language=\"JavaScript\">window.location=\"index.php\";</script>";
"Bring forth therefore fruits meet for repentance:" Matthew 3:8
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • Avatar de Usuario
  • Registrado: Dic 20, 2002
  • Mensajes: 8925
  • Loc: Seattle, WA & Phoenix, AZ
  • Status: Offline

Nota Julio 2nd, 2009, 12:17 am

Si no desea utilizar el Javascript se puede utilizar también una meta de refresco. Podrían ser más fiables en caso de que alguien tiene JavaScript desactivado.
Ozzu Hosting - Want your website on a fast server like Ozzu?
  • Bogey
  • Bogey
  • Genius
  • Avatar de Usuario
  • Registrado: Jul 14, 2005
  • Mensajes: 8211
  • Loc: USA
  • Status: Offline

Nota Julio 2nd, 2009, 11:12 am

Bigwebmaster escribió:
Si no desea utilizar el Javascript se puede utilizar también una meta de refresco. Podrían ser más fiables en caso de que alguien tiene JavaScript desactivado.

¿Funciona en la sección de cuerpo?
"Bring forth therefore fruits meet for repentance:" Matthew 3:8

Publicar Información

  • Total de mensajes en este tema: 13 mensajes
  • Usuarios navegando por este Foro: No hay usuarios registrados visitando el Foro y 123 invitados
  • No puede abrir nuevos temas en este Foro
  • No puede responder a temas en este Foro
  • No puede editar sus mensajes en este Foro
  • No puede borrar sus mensajes en este Foro
  • No puede enviar adjuntos en este Foro
 
 

© 2011 Unmelted, LLC. Ozzu® es una marca registrada de Unmelted, LLC