Soy nuevo en esto de la programacion php y bueno tengo un problema en mi codigo
lo que quiero es poder insertar 2 fotos o mas en un solo registro y no se como hacerlo,
llevo dian intentando y nada, inserte otro campo que se llama imagesll para poder guardar alli la otro foto
y que al momento de instertar la informacion de tal persona haga una busqueda y que me muestre las imagenes de el solamenete les dejo el codigo para que lo chequen.
les agradeceria mucho que me ayuden gracias.
este codigo es de mi upload.php
<?php define ('MAX_FILE_SIZE', 1024 * 150); ?>
<?php require_once('Connections/conn.php');
require_once('menu.html');
?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "uploadImage")) {
// make sure it's a genuine file upload
if (is_uploaded_file($_FILES['image']['tmp_name'])) {
// replace any spaces in original filename with underscores
$filename = str_replace(' ', '_', $_FILES['image']['name']);
// get the MIME type
$mimetype = $_FILES['image']['type'];
if ($mimetype == 'image/pjpeg') {
$mimetype= 'image/jpeg';
}
// create an array of permitted MIME types
$permitted = array('image/gif', 'image/jpeg', 'image/png');
$ip=$_SERVER['REMOTE_ADDR'];
$cpu=gethostbyaddr($_SERVER['REMOTE_ADDR']);
// upload if file is OK
if (in_array($mimetype, $permitted)
&& $_FILES['image']['size'] > 0
&& $_FILES['image']['size'] <= MAX_FILE_SIZE) {
switch ($_FILES['image']['error']) {
case 0:
// get the file contents
$image = file_get_contents($_FILES['image']['tmp_name']);
// get the width and height
$size = getimagesize($_FILES['image']['tmp_name']);
$width = $size[0];
$height = $size[1];
$insertSQL = sprintf("INSERT INTO dm_images (filename, mimetype, caption, image, width, height, per_nom, per_app, per_apm, ip, cpu) VALUES (%s, %s, %s, %s, %s,%s, %s,%s,%s,%s,%s)",
GetSQLValueString($filename, "text"),
GetSQLValueString($mimetype, "text"),
GetSQLValueString($_POST['caption'], "text"),
GetSQLValueString($image, "text"),
GetSQLValueString($width, "int"),
GetSQLValueString($height, "int"),
GetSQLValueString($_POST['txt_pernom'], "text"),
GetSQLValueString($_POST['txt_perapp'], "text"),
GetSQLValueString($_POST['txt_perapm'], "text"),
GetSQLValueString($ip,"text"),
GetSQLValueString($cpu,"text")
);
mysql_select_db($database_conn, $conn);
$Result1 = mysql_query($insertSQL, $conn) or die(mysql_error());
if ($Result1) {
$result = "$filename guardada con exito.";
} else {
$result = "Error al subir $filename. Por favor intente de nuevo.";
}
break;
case 3:
case 6:
case 7:
case 8:
$result = "Error al subir $filename. Por favor intente de nuevo.";
break;
case 4:
$result = "No ha seleccionado imagen para ser guardada.";
}
} else {
$result = "$filename es demaciado grande o no es una imagen.";
}
}
}
?>
<!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=iso-8859-1" />
<title>Guardar Registro</title>
<LINK href="example.css" rel="stylesheet" type="text/css">
</head>
<body>
<?php
// if the form has been submitted, display result
if (isset($result)) {
echo "<p><strong>$result</strong></p>";
}
?>
<form action="<?php echo $editFormAction; ?>" method="POST" enctype="multipart/form-data" name="uploadImage" id="uploadImage">
<fieldset>
<legend>Persona Reportada</legend>
<label> Nombre: <input type="text" name="txt_pernom" id="txt_pernom" /></label>
<br />
<label>A. Paterno: <input type="text" name="txt_perapp" id="txt_perapp" /></label>
<label>A. Materno: <input type="text" name="txt_perapm" id="txt_perapm" /></label>
</fieldset>
<input type="hidden" name="MAX_FILE_SIZE" value="<?php echo MAX_FILE_SIZE; ?>" />
<br />
<label for="image">Cargar imagen:</label>
<input type="file" name="image" id="image" />
<label for="image">Cargar imagen:</label>
<input type="file" name="image" id="image" />
<p>
<label for="caption">Descripción:</label>
<textarea name="caption" id="caption"></textarea>
</p>
<p>
<input type="submit" name="upload" id="upload" value="Guardar" />
</p>
<input type="hidden" name="MM_insert" value="uploadImage" />
</form>
</body>
</html>
este es del archivo imprimir.php
<?php require_once('Connections/conn.php');
require_once('menu.html');
?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
mysql_select_db($database_conn, $conn);
$ip=$_SERVER['REMOTE_ADDR'];
$cpu=gethostbyaddr($_SERVER['REMOTE_ADDR']);
$query_rsImpresion = "SELECT image_id, caption, fexa, per_nom, per_app, per_apm, FROM dm_images WHERE dm_images.fexa > '2011-08-02' + '00:00:00' and dm_images.fexa< '2011-08-02' + '59:59:59'";
$rsImpresion = mysql_query($query_rsImpresion, $conn) or die(mysql_error());
$row_rsImpresion = mysql_fetch_assoc($rsImpresion);
$totalRows_rsImpresion = mysql_num_rows($rsImpresion);mysql_select_db($database_conn, $conn);
$query_rsImpresion = "SELECT image_id, caption, fexa, per_nom, per_app, per_apm, FROM dm_images WHERE ip='".$ip."' and cpu='".$cpu."' and dm_images.fexa > CONCAT(YEAR(NOW()),'-',MONTH(NOW()),'-',DAY(NOW()),' ' ,'00:00:00')";
$rsImpresion = mysql_query($query_rsImpresion, $conn) or die(mysql_error());
$row_rsImpresion = mysql_fetch_assoc($rsImpresion);
$totalRows_rsImpresion = mysql_num_rows($rsImpresion);
?>
<!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>Impresion</title>
<LINK href="example.css" rel="stylesheet" type="text/css">
</head>
<body>
<?php do { ?>
<table width="200" border="1" class="alternate_rows">
<tr>
<td><?php echo substr($row_rsImpresion['fexa'],8,2)."-".substr($row_rsImpresion['fexa'],5,2)."-".substr($row_rsImpresion['fexa'],0,4)." ".substr($row_rsImpresion['fexa'],11,; ?></td>
<td> </td>
<td><?php echo ucfirst($row_rsImpresion['per_nom']); ?><br />
<?php echo ucfirst($row_rsImpresion['per_app']); ?> <?php echo ucfirst($row_rsImpresion['per_apm']); ?><br /></td>
</tr>
<tr>
<td colspan="3"><img src="show.php?image_id=<?php echo $row_rsImpresion['image_id']; ?>" width="360" height="240" alt="img" /><img src="show.php?image_id=<?php echo $row_rsImpresion['image_id']; ?>" width="360" height="240" alt="img" /></td>
<td colspan="3"> </td>
</tr>
<tr>
<td colspan="3"><?php echo ucfirst($row_rsImpresion['caption']); ?></td>
</tr>
</table>
<br />
<br />
<br />
<?php } while ($row_rsImpresion = mysql_fetch_assoc($rsImpresion)); ?>
</body>
</html>
<?php
mysql_free_result($rsImpresion);
?>