0

I'm trying to convert an old php query I found which displays images in a table to mysqli, but I always get the 'no images in database' error.

I have double checked my SQL and tested it against the database, and changed all the reference to mysql to mysqli. Could anyone help?

<?php
    require( '../connect_db.php' ) ;
    $pull_images = mysqli_query("
        select 
        dbo_infoseek_source.id, 
        dbo_infoseek_source.fulltitle,
        dbo_infoseek_source_additionals.url
        from dbo_infoseek_source, dbo_infoseek_source_additionals
        where dbo_infoseek_source_additionals.type = 'In-game screen'
        and dbo_infoseek_source.id = dbo_infoseek_source_additionals.id
        and dbo_infoseek_source.type = 'Arcade: Adventure'
        order by dbo_infoseek_source.fulltitle asc");


    if( @mysqli_num_rows( $pull_images ) > 0 ) {
        echo '<table>';
        $count = 0;
        while( $row = mysqli_fetch_array( $pull_images ) ) {
            if( $count == 0 ) {
                echo "<tr><td>";
            } else {
                echo "<td>";
            }
            echo '<img src="' . $row['dbo_infoseek_source_additionals.url'] . '" alt="' . $row['dbo_infoseek_source.fulltitle'] . '" />';
            if( $count == 3 ) {
                echo '</td></tr>';
                $count = 0;
            } else {
                echo '<td>';
                $count++;
            }
        }
        $cells_left = 4 - $count;
        if( $cells_left > 0 ) {
            $i = 0;
            while( $i <= $cells_left ) {
                echo '<td></td>';
                $i++;
            }
            echo '</tr>';
        }
        echo '</table>';
    } else {
        echo "No images in the database.";
    }
?>

Thanks in advance

zajonc
  • 1,935
  • 5
  • 20
  • 25
  • If you weren't (childishly) using `@` to supress errors, maybe you'd have gotten the warning that you're calling mysqli_query incorrectly. Supressing errors is NEVER a good idea, especially when you know the code isn't working right. It's the programming equivalent of stuffing your fingers in your ears and going "lalalalala can't hear you". – Marc B Jul 26 '16 at 19:11
  • I didn't know I was surpressing errors, so its a bit out of order to say its childish... Don't forget I'm converting existing code. You need a chill pill my man. Thanks so much for the really helpful answer. Much appreciated. – Peter Jones Jul 26 '16 at 19:45

0 Answers0