#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    3
    Rep 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

    ------------------
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    4
    Rep Power
    0
    One problem that I see with your transfer of the variables is that you are using the variables of $text_foto[] and $foto[] in the first form but then you use $foto_size[] and $foto_name[] without designating those variables from the data from the previous form. Your second page looks correct other than the fact that variables that it is using do not have values for them so the answer would be correct that the amount of photos is "0".

    You need to call $text_foto[] and $foto[] in the second page and format them into $foto_size[] and $foto_name[] for use later in the page.

    Hope this helps,

    Maven

    [This message has been edited by mavenman (edited June 05, 2000).]

Similar Threads

  1. uploading image then generating a mysql value
    By emp/ir:kal in forum PHP Development
    Replies: 2
    Last Post: February 10th, 2004, 10:10 AM
  2. uploading from php form / generating mysql value
    By emp/ir:kal in forum PHP Development
    Replies: 2
    Last Post: February 9th, 2004, 10:30 PM
  3. Uploading multiple images using paths all in same .txt file?
    By MarlboroMan in forum Perl Programming
    Replies: 3
    Last Post: February 3rd, 2004, 06:34 PM
  4. PHP and MYSQL to display images
    By foreverdita in forum PHP Development
    Replies: 2
    Last Post: January 23rd, 2004, 09:21 AM
  5. Replies: 4
    Last Post: January 2nd, 2004, 03:33 PM

IMN logo majestic logo threadwatch logo seochat tools logo