Jump to content

mysql image pagination issues


matthew9090

Recommended Posts

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>";
}
}

?>

 

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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)
?>

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.