
June 4th, 2000, 08:48 PM
|
|
Junior Member
|
|
Join Date: May 2000
Posts: 3
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Hello all,
I'm having a problem inserting photos into my MySQL database.
I have the following form to submit the photos:
===============
<form method="post" action="insertar_casa.php3" enctype="multipart/form-data">
<input type="text" name="text_foto[]" size="25" maxlength="25">
<input type="file" name="foto[]">
<input type="text" name="text_foto[]" size="25" maxlength="25">
<input type="file" name="foto[]">
<input type="text" name="text_foto[]" size="25" maxlength="25">
<input type="file" name="foto[]">
<input type="text" name="text_foto[]" size="25" maxlength="25">
<input type="file" name="foto[]">
<input type="submit" name="Submit" value="Ingresar Datos">
</form>
===============
I'm using the following code for the php processing file "insertar_casa.php3":
===========================================================
<?php
/* Set database variables */
$dbName = "mydatabase";
$pass = "mypassword";
/* Get the amount of photos submitted */
$foto_cuantity = 0;
for ($j=0; $j < 12; $j++) {
if ($foto_size[$j] != 0){
$foto_cuantity++;
print "The name of file number $j is $foto_name[$j].<p>";
}
}
print "The amount of photos you submitted is $foto_cuantity.<p>";
/* Insert each photo and corresponding text into the MySQL Database */
for ($i=0; $i < $foto_cuantity; $i++) {
$PSize = $foto_size[$i];
$mysqlphoto = addslashes(fread(fopen($foto[$i], "r"), $PSize));
mysql_connect("localhost","$dbName","$pass") or die("Unable to connect to MySQL server");
@mysql_select_db($dbName) or die("Unable to select database");
mysql_query("INSERT INTO imagenes (prop_num,titulo,file) VALUES($prop_num,'$text_foto[$i]',$mysqlphoto)");
}
?>
===================================================
But I always get the output "The amount of photos you submitted is O."
Does anyone have any idea why the second script doesn't recognize the uploaded files?
I'm pulling out my already spare amount of hair over this one. Can anybody see any mistakes I've made?
Thanks a million!
Bryan
------------------
|