You are here: Re: uploading several docs at once and inputting data into a db « PHP Programming Language « IT news, forums, messages
Re: uploading several docs at once and inputting data into a db

Posted by Tim Hunt on 08/09/06 00:41

Chris wrote:
> Hi Tim, thank you so much for getting back to me.
>
> I've reviewed a few multiple file upload tutorials/guidelines, and have had
> the best luck with the one I have posted below - I made adjustments as
> needed.
> The create meeting form works great - and the processing form (see below)
> inputs all data as defined in the meetings table. It also recognizes the
> $mtgid because it is printed out as part of the confirmation to the user.
> It looks to see if someone checked the upload docs checkbox, so there will
> be a heading with instructions to upload.


> if
> (move_uploaded_file($file_tmp,$upload_dir.$file_name)) {
> echo "File $i: ($file_name)
> Uploaded.<br>";
> echo "File $i: ($title)<br>";
> echo "File $i: ($desc)<br>";
> //enter file data into database
> mysql_select_db($database_website, $website);
> $doc_insert = "INSERT INTO meeting_docs
> VALUES ('', '$file_name', '$title', '$desc', '$mtgid')";
> $success = mysql_query($doc_insert);
> //create variable to hold insert values
>
> }else{
> echo "File $i: Failed to
> upload.<br>";
> }#end of (move_uploaded_file).
>
> }#end of (file_exists).
>
> }#end of (!is_uploaded_file).
>
> }#end of (for loop).
> # print back button.
> echo "»<a href=\"$_SERVER[PHP_SELF]\">add more documents</a>";

Hi Chris

No I can't see what the problem is either.

I'm assuming its working like you expect apart until the part above
where the uploaded file's are moved then details recorded in the
meeting_docs table, is that right?

Will you try this debugging stuff.. Call mysql_error() after
mysql_query to see if the query syntax is at fault, print out
$doc_insert and try running the query by hand in phpmyadmin or mysql
cli, are you getting the expected number of "file $i: Uploaded br>"
messages?

I did wonder if the problem was inserting '' into the auto_increment
column, the mysql manual says only NULL or 0 will trigger an auto
increment - I've double checked the manual but I'm still not sure if ''
is treated the same as 0. It may not make a difference but would you
try INSERT ... VALUES(NULL, '$file_name'...) just in case.

Btw, top posting can make it hard for most people using newsreader
clients to follow the thread - could you put your reply to messages
underneath the previous message. Ta.

Cheers
Tim

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация