Hi im pretty knew to php and more to SQL but i’ve recently started writing my own scripts, the most recent being one to display a random image using data pulled from the data base.
[php] $dbcon = mysql_connect (“localhost”,“user_name”,“password”);
if (!$dbcon)
{
echo( “
Unable to connect to the database server at this time.
” );exit();
}
else
{
if (! @mysql_select_db(“database_name”,$dbcon))
{
echo ‘
The gallery database seems to be offline at the moment, please try again later.
’;exit();
}
else
{
$result = mysql_query(“SELECT * FROM Screenshots WHERE Catagory=‘game’ OR Catagory=‘trophys’ AND Auth=1 ORDER BY ImageDate DESC LIMIT 6”);
if (! $result)
{
echo’database down’;
exit();
}
else
{
$data = array();
while($row = mysql_fetch_array($result))
{
$data[] = $row[‘ImageName’];
}
$random = rand(0,5);
$img = $data[$random];
echo ’
The code works fine except for a small issue, it keeps pulling an image up that that is Auth=0 and I cant see why.
The only reason I can possibly think of is during testing I may have made it Auth=1 but 100% it is currently Auth=0 and still being pulled up for display.
Anyway hope someone can shed some light on this for me. Thanks in advance