0

I'm new here and new in php world. I'm making web page using mysql and php. Need to display on images and data like a search results on another page. In wamp I create a database Pic of data base

This is a search form with php search and php code

connection whit db is working

this is message

**( ! ) Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in C:\wamp\www\vezba 3\rezultati-pretrage.php

But im note for sure the problem is only in this line

Blow my head to figuring out this

PLEASE HELP

    <?php
$sql = "SELECT * FROM artikli";
if($result = mysqli_query($db, $sql)){
    if(mysqli_num_rows($result) > 0){
        echo "<table>";
            echo "<tr>";
                echo "<th>id</th>";
                echo "<th>cena</th>";
                echo "<th>model</th>";
                echo "<th>slika</th>";
            echo "</tr>";
        while($row = mysqli_fetch_array($result)){
            echo "<tr>";
                echo "<td>" . $row['id'] . "</td>";
                echo "<td>" . $row['cena'] . "</td>";
                echo "<td>" . $row['model'] . "</td>";
                echo "</br>";
                header("Content-type: image/png");
                echo '<img src="'.$row['slika'].'"/>';
            echo "</tr>";
        }
        echo "</table>";
    }
}   

// Close connection
mysqli_close($db);
?>
Ivan
  • 13
  • 5
  • 4
    Don't post photos of code, post the actual code. – Sean Dec 03 '16 at 00:01
  • 1
    Your error is probably on this line -> `echo "".""."";` You are already echoing that line, so you don't need to add `echo` before the php variable. Just do -> `echo "".""."";` – Sean Dec 03 '16 at 00:04
  • Thanks Sean for answer this part (line) is working great. but pop-up a new problem it wont display nothing not even error – Ivan Dec 03 '16 at 07:27
  • You can't do `header("Content-type: image/png");` in the middle of your html code. You are probably getting a [`headers already sent`](http://stackoverflow.com/questions/8028957/how-to-fix-headers-already-sent-error-in-php), but you may not see it if error reporting is turned off. Since your `$row['slika']` is the name of a file, and not an actual image, it is unnecessary anyway. – Sean Dec 04 '16 at 00:19

1 Answers1

0

It's pretty hard to see what the code is, but Line 26 definitely needs to change to this:

// i prefer single quoting to double quoting most of the time
// but it's definitely clearer here since you need attributes
echo '<td><img src="'.$row['slika'].'"/></td>';

edit

You have an if here...add an else like this:

if ($result = mysqli_query($db, $sql)) {
   // ... code
} else {
  echo 'mysqli error? ';
  printf("Errormessage: %s\n", mysqli_error($db));
}

Also, if the page is white, you may not be seeing your errors. Be sure to know where your php error log is;

Community
  • 1
  • 1
WEBjuju
  • 5,797
  • 4
  • 27
  • 36
  • Thanks WEBjuju Your answer is working no more error but funny thing do not display nothing, empty page. I edited my question here is a useble code – Ivan Dec 03 '16 at 07:36
  • you may just have a query or file error – WEBjuju Dec 03 '16 at 13:42
  • something is wrong for shure. I`ll try different code to solve the problem. Thank you anyway – Ivan Dec 03 '16 at 19:28