I would like to incorporate this code into current PHP script:
$servername = "localhost";
$username = "root";
$password = "password";
$dbname = "GoogleMaps";
$vessel = "Test";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
};
$sql = "SELECT Coordinates FROM $vessel order by id desc limit 1";
$result = $conn->query($sql);
while($row = $result->fetch_assoc()) {
$myLatlong = $row['Coordinates'];
};
$conn->close();
The server is complaining about line:
$myLatlong = $row['Coordinates'];
with the error:
PHP Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING
Could somebody please give me an indication what could be wrong here, as this same code is working in a PHP script that includes only this code, it is not working only when I copy/paste it into a current script?