Jump to content

One Record Limit on database?


nineninefour

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]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.