Php Error T_encapsed_and_whitespace
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack parse error: syntax error, unexpected t_encapsed_and_whitespace, expecting ']' Overflow the company Business Learn more about hiring developers or posting ads with us t_encapsed_and_whitespace wordpress Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community unexpected t_constant_encapsed_string of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING up vote 7 down vote favorite syntax error, unexpected t_variable I have been staring at this code for hours now and I cannot figure out where my mistake is. I know this syntax error usually comes up because of some missing or out of place curly brace or some issue with single/double quotes and I'm not sure there is one anywhere in my code. I am only trying to fix my syntax right now so I can get the code to
Unexpected T_string
completely compile. Any help would be much appreciated. Here is my code:
Please put your comments below.
Name:
Comment:
END; } function process_form() { print "adding comment...
"; $Name = $_POST['WholeName']; $Comment = $_POST['Comment']; if( preg_match("^[a-zA-Z]+$", $Name)) { if( preg_match("^[a-zA-Z0-9]_\-\'[.?!]+$", $Comment)) { $sql = "insert into comments1 values ( '$Name', '$Comment')"; $result = mysql_query($sql) or die("Mysql query failed"); } else { print "invalid name"; } } else { print "invalid characters"; } } $db = mysql_connect("", "", ""); if (!$db) { print "Error - Could not connect to mysql"; exit; } $er = mysql_select_db(""); if (!$er) { print "Error - Could not connect to comments1 database"; exit; } if (isset($_POST['stage']) && ('process' == $_POST['stage'])) { process_form(); } else { print_form(); } ?> php parsing syntax share|improve this question edited Dec 6 '11 at 12:46 deceze 304k44386531 asked Dec 6 '11 at 12:41 user1083482 41113 9 It's good practice to state wherehere for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies
Heredoc In Php
of this site About Us Learn more about Stack Overflow the company parse error: syntax error, unexpected end of file Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges undefined index php Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: http://stackoverflow.com/questions/8400018/syntax-error-unexpected-t-encapsed-and-whitespace-expecting-t-string-or-t-vari Sign up How do I fix this “T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING” error? up vote 0 down vote favorite I am writing a simple php registration page using MySQL as the database. I am quite new to it and I came across this error: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\xampp\htdocs\w4wregister.php on line http://stackoverflow.com/questions/4558223/how-do-i-fix-this-t-encapsed-and-whitespace-expecting-t-string-or-t-variable-o 34 I have gone through the little bit of code that I added that caused that error for the past hour and cannot see anything wrong with it. Below I have the code I added. I believe I was able to narrow it down to the while statement but I gave the other code for context. if($r) { echo "
Thanks for registering!
Current Users:
"; $q2 = "SELECT username AS users FROM users ORDER BY registration_date"; $r2 = @mysqli_query ($dbc, $q2); //gets all users if ($r2) { echo '
Current Users:
"; $q2 = "SELECT username AS users FROM users ORDER BY registration_date"; $r2 = @mysqli_query ($dbc, $q2); //gets all users if ($r2) { echo 'Username |
$row['users'] |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company http://stackoverflow.com/questions/26887704/parse-error-syntax-error-unexpected-t-encapsed-and-whitespace Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million http://www.forosdelweb.com/f18/parse-error-syntax-error-unexpected-t_encapsed_and_whitespace-expecting-t_string-616222/ programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE up vote 1 down vote favorite I might have a syntax error or something but syntax error, I don't see nothing. On the echo line, I have the error : [error] [client] PHP Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /var/www/slimtest/views/nuevo.php on line 89 Maybe you can help, because I don't see the error D"= php html compiler-errors syntax-error whitespace share|improve this question edited Nov 12 '14 at 13:15 Machavity syntax error, unexpected 18.2k133259 asked Nov 12 '14 at 13:04 Juan 83 add a comment| 4 Answers 4 active oldest votes up vote 0 down vote accepted This should work: share|improve this answer answered Nov 12 '14 at 13:11 Deepak 1,591516 Thanks, worked perfect. –Juan Nov 12 '14 at 14:10 add a comment| up vote 0 down vote When using array variables inside of strings it's usually better to use the complex syntax: echo "(''.'
)"; Alternatively you can remove the quotes in the array key: echo "(''.'
)"; PHP String Variable Parsing share|improve this answer answered Nov 12 '14 at 13:10 Jim 17.5k32859 add a comment| up vote 0 down vote Try changing echo line to this: echo ''; share|improve this answer answered Nov 12 '14 at 13:10 ronalds 9819 add a comment| up vote 0 down vote This line is a mess echo "(''.'
)"; First off, you can't use other characters around an
error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING o Estas en el tema de Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING o en el foro de PHP en Foros del Web. Hola, estaba configurando unas cositas anti span de la web e inclui este codigo, me da un fallo en la linea: $bbcode_uid = '' ; ... #1 (permalink) 18/08/2008, 14:15 K-anario Fecha de Ingreso: abril-2006 Mensajes: 123 Antigüedad: 10 años, 5 mesesPuntos: 0 Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING o Hola, estaba configurando unas cositas anti span de la web e inclui este codigo, me da un fallo en la linea: $bbcode_uid = '' ; if (!eregi("^multipart/form\-data’,trim($_SERVER['CONTENT_TYPE']))) $poll_length = ( isset($HTTP_POST_VARS['poll_length']) && $is_auth['auth_pollcreate'] ) ? $HTTP_POST_VARS['poll_length'] : ''; $bbcode_uid = '' ; if (!eregi("^multipart/form\-data’,trim($_SERVER['CONTENT_TYPE']))) { echo “No se acepta spam. Tómeselas.”; exit(); } prepare_post($mode, $post_data, $bbcode_on, $html_on, $smilies_on, $error_msg, $username, $bbcode_uid, $subject, $message, $poll_title, $poll_options, $poll_length); if ( $error_msg == '' ) { No lo veo ¡¡¡ ayuda please #2 (permalink) 18/08/2008, 14:17 Ronruby Fecha de Ingreso: julio-2008 Ubicación: 18°30'N, 69°59'W Mensajes: 4.879 Antigüedad: 8 años, 3 mesesPuntos: 416 Respuesta: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting Siempre que PHP muestra uno de esos errores es porque te falto cerrar algo en la linea por encima de la del error. Revisa que hayas cerrado todas las llaves y eso. $bbcode_uid = '' ; if (!eregi("^multipart/form\-data',trim($_SERVER['CONTENT_TYPE']))) #3 (permalink) 18/08/2008, 14:19 K-anario Fecha de Ingreso: abril-2006 Mensajes: 123 Antigüedad: 10 años, 5 mesesPuntos: 0 Respuesta: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting Cita: Iniciado por Ronruby Siempre que PHP muestra uno de esos errores es porque te falto cerrar algo en la linea por encima de la del error. Revisa que hayas cerrado