Jump to content

nineninefour

New Members
  • Posts

    6
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

nineninefour's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. 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]
  2. Alright, I've got another one. I have a form designed to facilitate multiple image uploads. I have also writen this pictured script to move them into an images folder. Each form has a random number ($num) generated for it. What I want to do is rename all the images uploaded to $num_1.ext, $num_2.ext, $num_3.ext, etc. Here is the code I have, can someone guide me? Thanks! [code] $num = rand(0, 99999); $umask = umask(0); $uploaddir = "items/images/"; $tmp_name = $_FILES["userfile"]["tmp_name"][$key]; $name = $_FILES["userfile"]["name"][$key]; foreach($_FILES['userfile']['name'] as $key => $name)   {      move_uploaded_file($tmp_name, "$uploaddir/$name");   } ?> [/code]
  3. Bump [img src=\"style_emoticons/[#EMO_DIR#]/unsure.gif\" style=\"vertical-align:middle\" emoid=\":unsure:\" border=\"0\" alt=\"unsure.gif\" /]
  4. [!--quoteo(post=382413:date=Jun 10 2006, 09:42 PM:name=phpuesr1)--][div class=\'quotetop\']QUOTE(phpuesr1 @ Jun 10 2006, 09:42 PM) [snapback]382413[/snapback][/div][div class=\'quotemain\'][!--quotec--] [code] if($_COOKIE[user]!="") { $file=@fopen"_private/chat_users.txt","a"; @fwrie$file,$_COOKIE[user]; @fclose$file; $file=@fopen"_private/chat_users.txt","r"; $users=@fread$file,filesize("_private/chat_users.txt"); @fclose($file); } [/quote] Look at line 4. fwriTe needs to have a "t" in it.
  5. Hello! Well, I've done my best. I've googled, ask.comed, read the documentation and searched the forums. I'm trying to move uploaded files to an already created directory: Here's the (abbreviated) form. I'm aware there is no doctype or anything. I'm just trying to get the php to work first: [code] <html> <body> <form name="upload" enctype="multipart/form-data" action="uploadtest.php" method="post"> Item Name: <p> Upload Your Pictures! <input  type="file" name="userfile[]" /> <input  type="file" name="userfile[]" /> <input  type="file" name="userfile[]" /> <input  type="file" name="userfile[]" /> <input  type="file" name="userfile[]" /> </p> <br /> <input type="submit" value="Add New item!" /> </form> </body> </html> [/code] And here is the php: [code] <?php $dbh=mysql_connect ("localhost", "XXXXXXXXX", "XXXXXXX")         or die ('I cannot connect to the database because: ' . mysql_error());      mysql_select_db ("ninenine_xxxxxxxxx"); $num = rand(0, 99999); $umask = umask(0); $default = "default.html"; $dest = "items/$num/default.html"; $uploaddir = "items/$num/images/"; $uploadfile = $uploaddir . basename($_FILES['userfile']['name'][$key]); mkdir("items/$num", 0777); //gets created no prob mkdir("$uploaddir", 0777); //also works great umask($umask); copy($default, $dest); //copies my default file into the new directory, works great foreach($_FILES['userfile']['name'] as $key => $value)     {        move_uploaded_file($_FILES['userfile']['tmp_name'][$key], $uploadfile);  //THIS IS LINE 27     } ?> [/code] Here is the error i get: [code] Warning: move_uploaded_file(items/32142/images/): failed to open stream: Is a directory in /home/ninenine/public_html/vegasitems/uploadtest.php on line 27 Warning: move_uploaded_file(): Unable to move '/tmp/phppnPllB' to 'items/32142/images/' in /home/ninenine/public_html/vegasitems/uploadtest.php on line 27 Warning: move_uploaded_file(items/32142/images/): failed to open stream: Is a directory in /home/ninenine/public_html/vegasitems/uploadtest.php on line 27 Warning: move_uploaded_file(): Unable to move '/tmp/phpWjD0Ml' to 'items/32142/images/' in /home/ninenine/public_html/vegasitems/uploadtest.php on line 27 [/code]
×
×
  • 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.