Jump to content

Archived

This topic is now archived and is closed to further replies.

nineninefour

One Record Limit on database?

Recommended Posts

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:

[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++;
   
}

?>

[/code]

Share this post


Link to post
Share on other sites
I don't understand... you're always updating the same record... $num never changes.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.