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
try this
echo $sqlupdate1 = "UPDATE table SET commodity_quantity=$qty WHERE user='".$rows['user']."' ";
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
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 />";
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?
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.
Related Topics
Select Within 20 Kilometers Based on Latitude/Longitude
How to Take a Photo and Send to Http Post Request with Android
How to Send Multiple Attachment in Single Mail in PHP
Sort Xml via Attribute Value PHP
Can Anyone Get Access to My PHP Source Code
Getting the Full Url Including the Query String After Hash
How to Round to Nearest Thousand
PHP Strtotime +1 Month Adding an Extra Month
How to Apply a Function to an Array
Fatal Error: Class 'Mongodb\Driver\Manager' Not Found
New MySQLi(): How to Intercept an 'Unable to Connect' Error
Sort an Array with Special Characters in PHP
Using SQLite3 in PHP How to Count the Number of Rows in a Result Set
PHP Get Content of Http 400 Response
How to Easily Convert Dates from Utc via PHP
PHP Exec: Does Not Return Output
Codeigniter - File Upload Required Validation
How to Send a Bytearray (From Flash) and Some Form Data to PHP