matthew9090 Posted November 11, 2010 Share Posted November 11, 2010 i've found a pagination script of the internet but the image comes up blank. I've stored it in a largeblob. When i check the html it says 'array[name]' as the image pz help me heres the code: <?php //connection stuff here $page = 1; if ( isset( $_GET['page'] ) ) { $page = (int) $_GET['page']; } $query = mysql_query("SELECT COUNT(*) FROM `upload`",$link); list( $total ) = mysql_fetch_row( $query ); $total = ceil( $total / $perPage ); $start = ( $perPage * ( $page - 1 ) ); $limit = ''; $show = true; if ( $total > 1 ) { $limit = " LIMIT {$start}, {$perPage}"; } else { $show = false; } $query = mysql_query("SELECT * FROM `upload` ORDER BY `id`{$limit}"); while( $row = mysql_fetch_assoc( $query ) ) { echo "<img src=\"{$row['file_name']}\" alt=\"{$row['name']}\" title=\"{$row['name']}\" />"; } if ( $show ) { $prev = $page - 1; $next = $page + 1; if ( $prev > 0 ) { echo "<a href=\"{$thispage}?page={$prev}\">[PREV]</a>"; } if ( $next < $total ) { echo "<a href=\"{$thispage}?page={$next}\">[NEXT]</a>"; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/218414-mysql-image-pagination-issues/ Share on other sites More sharing options...
Adam Posted November 11, 2010 Share Posted November 11, 2010 I don't think you'd need a large blob for an image, it's limit's about 4gig... But anyway, that's a little unusual. Can you show us what a print_r() shows the array contains? I'm thinking you may have a problem INSERTING the record, as apposed to retrieving it. If you check the data in a database administrator like PHPMyAdmin, do you see valid names? Quote Link to comment https://forums.phpfreaks.com/topic/218414-mysql-image-pagination-issues/#findComment-1133132 Share on other sites More sharing options...
matthew9090 Posted November 11, 2010 Author Share Posted November 11, 2010 it comes up with this in the database: id name file_name type_of_file 1 file [bLOB - 11 Bytes] Array[type] 2 another file [bLOB - 11 Bytes] Array[type] the insert script: <?php //connection stuff $sql="INSERT INTO upload (name, file_name, type_of_file, size) VALUES ('$_POST[name]','$_FILES[file][name]','$_FILES[file][type]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "Idea name: " . $_POST["name"] . "<br />"; echo "Upload: " . $_FILES["file"]["name"] . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; echo "<b>Upload sucessful!</b>"; mysql_close($con) ?> Quote Link to comment https://forums.phpfreaks.com/topic/218414-mysql-image-pagination-issues/#findComment-1133135 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.