-1

I'm trying to pass $row['uuid'] to the end of a URL without success so that it opens up a new window to display the jpeg file which is located on a network drive.

The code I have been trying is

echo'<table border="1" ><th >Date and Time</th><th>Plate</th>   <th>Confidence</th><th>Image Name</th>';
while($row = mysql_fetch_array($result)) {
    echo "<tr>";
    echo "<td>" . $row['dt'] . "</td>";
    echo "<td>" . $row['plate'] . "</td>";
    echo "<td>" . $row['confidence'] . "</td>";
echo "<td><a href='http://192.xxx.x.xx/Pictures/plates/.$row['uuid'] .' target='blank_'>" . $row['uuid'] . "</a></td>";
    echo "</tr>";
}
echo "</table>";

The error I keep getting is:

PHP Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING)

I have tried different ways to add $row['uuid'] to the end of the URL with no success.

Tunaki
  • 132,869
  • 46
  • 340
  • 423

3 Answers3

2

You were just missing a " try this and see if it works

echo'<table border="1" ><th >Date and Time</th><th>Plate</th>      <th>Confidence</th><th>Image Name</th>';
while($row = mysql_fetch_array($result)) {
echo "<tr>";
echo "<td>" . $row['dt'] . "</td>";
echo "<td>" . $row['plate'] . "</td>";
echo "<td>" . $row['confidence'] . "</td>";
echo "<td><a href='http://192.xxx.x.xx/Pictures/plates/'".$row['uuid'] ."' target='blank_'>" . $row['uuid'] . "</a></td>";
echo "</tr>";
}
echo "</table>";
0

Hi just do it without the dots:

echo'<table border="1" ><th >Date and Time</th><th>Plate</th>   <th>Confidence</th><th>Image Name</th>';
while($row = mysql_fetch_array($result)) {
    echo "<tr>";
    echo "<td>" . $row['dt'] . "</td>";
    echo "<td>" . $row['plate'] . "</td>";
    echo "<td>" . $row['confidence'] . "</td>";
echo "<td><a href='http://192.xxx.x.xx/Pictures/plates/".$row['uuid']."' target='blank_'>" . $row['uuid'] . "</a></td>";
    echo "</tr>";
}
echo "</table>";

saftly add .jpg

echo "<td><a href='http://192.xxx.x.xx/Pictures/plates/".$row['uuid'].".jpg' target='blank_'>" . $row['uuid'] . "</a></td>";
    echo "</tr>";
volkinc
  • 2,143
  • 1
  • 15
  • 19
0

The problematic line obviously is this one:

echo "<td><a href='http://192.xxx.x.xx/Pictures/plates/.$row['uuid'] .' target='blank_'>" . $row['uuid'] . "</a></td>";

You are using 2 methods here to get your $row['uuid'] into the string. The latter method, stopping the string and concatenating it with the . operator, works fine.

However, the first method, directly inserting it in a double-quoted string, does not work with array indices. Also, you do not need concatenation dots . there. Either use the other method

echo "<td><a href='http://192.xxx.x.xx/Pictures/plates/" . $row['uuid'] . "' target='blank_'>" . $row['uuid'] . "</a></td>";

or encapsulate your variable inside the string with curly braces:

echo "<td><a href='http://192.xxx.x.xx/Pictures/plates/{$row['uuid']}' target='blank_'>" . $row['uuid'] . "</a></td>";
Felk
  • 7,720
  • 2
  • 35
  • 65