0

trying to display image from database. last image to 1st.

but getting error:
Warning: mysql_query() expects parameter 1 to be string, resource given in C:\xampp\htdocs\a_upload\gallery.php on line 12
Warning: mysql_fetch_assoc() expects parameter 1 to be resource, null given in C:\xampp\htdocs\a_upload\gallery.php on line 26

    $sql = mysql_query("SELECT * FROM image WHERE user_id = $id");
    $result = mysql_query($sql); //get access to image table



while($row = mysql_fetch_assoc($result))
                        {
                            echo"<td> ";
                                    $image_db = $row['image'];
                                    $src = "data:image/gif;base64," . $image_db;
                                    echo" <img src=\"$src\" width='130px' height='130px' class='image_p' />";
                            echo"</td>";
                                    $count++;
                                    if($count == 5)       //5 rows
                                    {
                                        echo "</tr><tr>"; // Start a new row at 6 cells
                                        $count = 0;
                                    }
                            }
3
Contributors
4
Replies
5
Views
5 Years
Discussion Span
Last Post by hwoarang69
0

At a glance, I can see this issue:
Your code on line 1 executes the query "SELECT * FROM image WHERE user_id = $id". Then it stores the result of the query in $sql. On line two you're trying to execute another query, but you're passing it the result of the first one. Doesn't really make sense. Just get rid of line 2, and maybe change "$sql" in line 1 to "$result". That or get rid of "mysql_query(" and ")" on line 1.

0

thanks, do you know how can i change my $result so that iam geting image starting from last one?

1

Post solved? Or is this question still live?

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.