nineninefour Posted July 4, 2006 Share Posted July 4, 2006 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 https://forums.phpfreaks.com/topic/13612-one-record-limit-on-database/ Share on other sites More sharing options...
fenway Posted July 4, 2006 Share Posted July 4, 2006 I don't understand... you're always updating the same record... $num never changes. Link to comment https://forums.phpfreaks.com/topic/13612-one-record-limit-on-database/#findComment-52748 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.