Skip to content Skip to sidebar Skip to footer

Syntax Error, Unexpected '' (T_ENCAPSED_AND_WHITESPACE), Expecting Identifier

fetch_assoc()) { echo ''; } $result->free(); ?> If I do echo $row[

Solution 1:

Wrap it with curly braces:

echo "<input type =\"submit\" name=\"naam\" value=\"{$row['naam']}\">";

Sidenote: If your string contains characters like " double quotes this will prematurely terminate it and break the markup, add htmlspecialchars to make sure before echoing:

$row['naam'] = htmlspecialchars($row['naam']);

Solution 2:

Your code mesh up with \ and double quote

use:-

echo "<input type ='submit' name='naam' value='".$row['naam']."'>";

Solution 3:

Check string concatenation operator in PHP.

Best looking solution for me:

while ($row = $result->fetch_assoc()) {
    echo "<input type='submit' name='naam' value='".$row['naam']."'>";
}

or

while ($row = $result->fetch_assoc()) {
    echo '<input type="submit" name="naam" value="'.$row['naam'].'">';
}

Make sure, that You escape earlier (before outputting) some chars with htmlspecialchars() to ensure that Your code will not ruin up:

$naam_value = htmlspecialchars($row['naam']);

Solution 4:

You need to use . because you want to concatenate the string between "" with the value of $row['naam']

echo "<input type =\"submit\" name=\"naam\" value=\".$row['naam'].\">";

Solution 5:

there is problem in your string:try

<?php 
while ($row = $result->fetch_assoc()) {
echo "<input type ='submit' name='naam' value='".$row['naam']."'>";
}
$result->free();
?>

Post a Comment for "Syntax Error, Unexpected '' (T_ENCAPSED_AND_WHITESPACE), Expecting Identifier"