Ver Mensaje Individual
  #3 (permalink)  
Antiguo 26/06/2008, 21:42
Avatar de asinox
asinox
 
Fecha de Ingreso: enero-2002
Ubicación: Santo Domingo
Mensajes: 2.712
Antigüedad: 24 años, 8 meses
Puntos: 6
Respuesta: while para mostrar imagenes desde la base de datos no funciona

claro aqui lo tienes

Esto tengo yo y me funciona de maravillas, solo necesito mostrar todas las imagenes de un usuario x o categoria

formulario
Código PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html xmlns="http://www.w3.org/1999/xhtml">
<
head>
<
meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<
title>Untitled Document</title>
</
head>
<
body>
<
form enctype="multipart/form-data" action="insert.php" method="post" name="changer">
<
input name="MAX_FILE_SIZE" value="102400" type="hidden" />
<
input name="image" accept="image/jpeg" type="file" />
<
input value="Submit" type="submit" />
</
form>
</
body>
</
html> 
Insertar
Código PHP:
// Create MySQL login values and 
// set them to your login information.
$username = "root";
$password = "";
$host = "localhost";
$database = "candente";

// Make the connect to MySQL or die
// and display an error.
$link = mysql_connect($host, $username, $password);
if (!
$link) {
    die(
'Could not connect: ' . mysql_error());
}

// Select your database
mysql_select_db ($database); 

// Make sure the user actually 
// selected and uploaded a file
if (isset($_FILES['image']) && $_FILES['image']['size'] > 0) { 

      
// Temporary file name stored on the server
      
$tmpName  = $_FILES['image']['tmp_name'];  
       
      
// Read the file 
      
$fp      = fopen($tmpName, 'r');
      
$data = fread($fp, filesize($tmpName));
      
$data = addslashes($data);
      
fclose($fp);
      

      
// Create the query and insert
      // into our database.
      
$query = "INSERT INTO testblob ";
      
$query .= "(image) VALUES ('$data')";
      
$results = mysql_query($query, $link);
      
      
// Print results
      
print "Thank you, your file has been uploaded.";
      
}else{
   print 
"No image selected/uploaded";
}

// Close our MySQL Link
mysql_close($link); 
ver la foto
Código PHP:
//header('Content-type: image/jpg');
$username = "root";
$password = "";
$host = "localhost";
$database = "candente";

@
mysql_connect($host, $username, $password) or die("Can not connect to database: ".mysql_error());

@
mysql_select_db($database) or die("Can not select the database: ".mysql_error());

$id = $_GET['image_ctgy'];

if(!isset(
$id) || empty($id)){
die(
"Please select your image!");
}else{

$query = mysql_query("SELECT * FROM testblob WHERE image_ctgy='".$id."'");
$row = mysql_fetch_array($query)
//while($row = mysql_fetch_array($query)){
    
$content = $row['image'];
//}

header('Content-type: image/jpg');
echo 
$content;

} 

Espero te ayude por que funciona perfecto, y espero que alguien me ayude a como mostrar mas de una foto...

Saludos
__________________
www.dataautos.com