Unexpected T_Encapsed_And_Whitespace, Expecting T_String or T_Variable or T_Num_String Error

syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING

Your problem is that you're not closing your HEREDOC correctly. The line containing END; must not contain any whitespace afterwards.

unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING error mail

I see that you wrote your parameters wrong. You wrote:

mail("$support_address","finalmessage",$headers);

It should be:

mail ($support_address, $subject, $message, $headers);

and remove this line

//mail("$email","Thank you for contacting us!","We will soon be in contact with you!",$header2);

PHP mail SYNTAX is:

mail ( string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]] )

Final code :

<?php
$name = $_POST['name'];
$surname = $_POST['surname'];
$email = $_POST['email'];
$support_address = "info@bkslegal";

if($name == "") {
//show somting error message
}
else
{
$Message = "From:".$name."<br />";
$Message .= "Email:".$email."<br />";
$Message .= "Message:". $_POST['message'];

$to = $support_address;
$subject = "new message";

// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

// Additional headers
$headers .= 'To: Name <$to>' . "\r\n";
$headers .= 'From: $name <$email>' . "\r\n";
$headers .= 'Cc: birthdayarchive@example.com' . "\r\n";
$headers .= 'Bcc: birthdaycheck@example.com' . "\r\n";

if(mail($to, $subject, $Message, $headers)) {
echo "Your message has been Sent";
} else {
echo "Mesage Error";
}
}
?>

Note : Use any mail library for prevent vulnerable to header injection like PHPMailer

unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING error

try this

echo $sqlupdate1 = "UPDATE table SET commodity_quantity=$qty WHERE user='".$rows['user']."' ";

How do I fix this T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING error?

Change:

echo "<tr><td> $row['users'] </td></tr>";

To:

echo "<tr><td> {$row['users']} </td></tr>";

Another option would be:

echo "<tr><td> ".$row['users']." </td></tr>";

Or even:

echo "<tr><td> ", $row['users'], " </td></tr>";

See the echo for more examples of how to employ variable interpolation.

syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE)

You have to change your code as below:

echo "<img src='$row[logo]' /><br />";

OR

echo "<img src='".$row[logo]."' /><br />";

unexpected '' (T_ENCAPSED_AND_WHITESPACE)

Try following:

<?php session_start();?>

<h6 id="myemail"> </h6>

<?php
echo "<script> document.getElementById('myemail').innerHTML = '{$_SESSION['email']}'; </script>";
?>

Please make sure that your echo should be placed after <h6 id="myemail"> </h6> is printed out.

Please pay attention to the order of the code.
You should make sure <h6 id="myemail"> </h6> is printed already before you echo script code.

syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) |[beginner]

Don't make it with echo if you already echo it. Just add $row['name'] as a normal variable, try like this:

echo "<tr id='".$row['name'].( ( $start % 2 ) == 0 ? " bgcolor=\"#FFFFFF\"" : " bgcolor=\"#E5E5E5\"" ) .">\n";

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:/... on line 10

You have syntax errors in your query. You need to have the curley brackets around every $_POST in your query, and your query should be ... VALUE (....)

change -

$sql= "INSERT INTO inside VALUES{($_POST['name']),($_POST['telephone']),($_POST['comment'])}";

to

$sql= "INSERT INTO inside VALUES ( {$_POST['name']}, {$_POST['telephone']},{$_POST['comment']})";

see

http://dev.mysql.com/doc/refman/5.6/en/insert.html

and

http://php.net/manual/en/language.types.string.php#language.types.string.parsing.complex


also, you should not be inserting user data directly into your database. take a look at

How can I prevent SQL injection in PHP?



Related Topics



Leave a reply



Submit