How to randomly retrieve images from my mysql database?

前端 未结 3 999
星月不相逢
星月不相逢 2021-01-25 21:42

Okay, so I\'ve made one php file to output the images this is the sample code for the output page:

mysql_connect (\" \",\" \",\" \") or die(mysql_error()); mysql_select_

3条回答
  •  感动是毒
    2021-01-25 21:58

    Cleaning up:

    $result = mysql_query("SELECT * FROM store ORDER BY RAND()");
    
    while($row = mysql_fetch_assoc($result)){       
        echo '';
    }
    

    You can also echo mysql_error(); to see if there are any errors in your mysql statements.

    You should also use mysql_real_escape_string() instead of addslashes()

    Or consider PDO for an even more secure solution.

    To debug, go to get.php?id=1. If you see an image get.php is working and the main file is not.

    Have you made sure that get.php connects to the database as well as the main file?

提交回复
热议问题