Jump to content


Photo

One Record Limit on database?


  • Please log in to reply
1 reply to this topic

#1 nineninefour

nineninefour
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 04 July 2006 - 03:04 AM

This is burning me out!

I have a simple form-to-database project on my site. User answers questionaire, php gives answer set a number, and stores the number and all entered information within a database.

This whole process works great for one record. Once one record has been added, the database stops updating completely! What gives?

Here is the code:

<?php
$dbh=mysql_connect ('localhost', 'xxx', 'xxx') 
        or die ('I cannot connect to the database because: ' . mysql_error());
     mysql_select_db ('xxx');

$num = rand(0, 99999);
$i = 1;
    
mysql_query
("INSERT INTO warehouse 
       (itemnumber, itemname, itemprice, newq, condition, contact, contactph, contactat, description) 
  VALUES
       ('$num', '$_POST[itemname]', '$_POST[price]', '$_POST[newq]', '$_POST[condition]', '$_POST[contact]', '$_POST[contactph]', '$_POST[contactat]', '$_POST[description]')");

foreach ($_FILES['userfile']['error'] as $key=> $error)
{
    
    $tmp_name = $_FILES['userfile']['tmp_name'][$key];
    $name = $_FILES['userfile']['name'][$key];
    
    if(is_uploaded_file($tmp_name))
    {
        $ext = strrchr($name, ".");
        $ext= str_replace('jpg','jpeg',strtolower($ext));
        rename($tmp_name,"images/$num" . "_" . "$i" . "$ext");
        $r = $num . _ . $i . $ext;
        chmod("images/$num" . "_" . "$i" . "$ext", 0644);
    
        mysql_query("UPDATE warehouse SET pic"."$i='../images/$r' WHERE itemnumber='$num'");
      
        $src = "images/$num" . "_" . "$i" . "$ext";
        $dest = 'images/previews/' . $num . _ . $i . _ . thumb . $ext;
        $fixed_size = 60;
    
        createthumb($src,$dest,$fixed_size,$square=true);
    
        mysql_query("UPDATE warehouse SET thumb"."$i='../$dest' WHERE itemnumber='$num'");
    }
    
    $i++;
    
}

?>



#2 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 04 July 2006 - 03:38 AM

I don't understand... you're always updating the same record... $num never changes.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users