incorrect Posted May 15, 2010 Share Posted May 15, 2010 Hi at first I say sorry for my bad english ok i have wrote a script to upload pictures an save them in a folder of my server! So long it works! But then I like to save the file of the picture or the name in a database! Is Somebody of you able to help me with this problem? I wont present the script hear because I think it would be not helpful =) so maybe you can post a short script what do what i want thank you Freddy Quote Link to comment https://forums.phpfreaks.com/topic/201840-upload-with-database/ Share on other sites More sharing options...
incorrect Posted May 15, 2010 Author Share Posted May 15, 2010 so maybe you can post a short script what do what i want or a little help which leads me to the correct way to solve the problem Greatings Incorrect Quote Link to comment https://forums.phpfreaks.com/topic/201840-upload-with-database/#findComment-1058945 Share on other sites More sharing options...
public-image Posted May 16, 2010 Share Posted May 16, 2010 Why not just create a new table in your database and simply record image uploads that way. For example a new image will create a new row in the table (the table may consist of: id; IP/Username; imageurl) - To insert such data just do a simple SQL insert with the script data obviously in some PHP after your script. Therefore you have a record of all images uploaded. To view your results just do a SQL Select statement to show your results in a table or so forth... I hope that helps in some way if not im sure youl find the help you need sooner or later Quote Link to comment https://forums.phpfreaks.com/topic/201840-upload-with-database/#findComment-1058953 Share on other sites More sharing options...
incorrect Posted May 16, 2010 Author Share Posted May 16, 2010 thank you for your answer! but i forgot to tell you, that i have a table in my database where it saves other information about the picture, which is about a think you like to sell, a car or something like this. So i have a place where i can save this but i dont know how to upload the picture AND save the file where it had been save in the database! is it now clearer what i like to have =) thank you for your help Quote Link to comment https://forums.phpfreaks.com/topic/201840-upload-with-database/#findComment-1059054 Share on other sites More sharing options...
RichardRotterdam Posted May 16, 2010 Share Posted May 16, 2010 ? I wont present the script hear because I think it would be not helpful =) I (and most likely others too) disagree. Try and post what you have so far for your upload script and people on the forum can help you / advice you how to correct or improve the script. but i forgot to tell you, that i have a table in my database where it saves other information about the picture, What does the table look like? Quote Link to comment https://forums.phpfreaks.com/topic/201840-upload-with-database/#findComment-1059098 Share on other sites More sharing options...
incorrect Posted May 16, 2010 Author Share Posted May 16, 2010 At first i have to say that I'm german so dont wonder why i have german expressions in the script! CREATE TABLE IF NOT EXISTS `artikel` ( `ID` int(11) NOT NULL AUTO_INCREMENT, `hauptkat` int(100) NOT NULL, `nebenkat` int(100) NOT NULL, `name` varchar(25) CHARACTER SET utf8 NOT NULL, `beschreibung` varchar(200) CHARACTER SET utf8 NOT NULL, `bild` varchar(100) CHARACTER SET utf8 NOT NULL, `preis` int(200) NOT NULL, `date` int(200) NOT NULL, `user` varchar(100) CHARACTER SET utf8 NOT NULL, `zustand` varchar(100) CHARACTER SET utf8 NOT NULL, `bild2` varchar(100) CHARACTER SET utf8 NOT NULL, `bild3` varchar(100) CHARACTER SET utf8 NOT NULL, `bild4` varchar(100) CHARACTER SET utf8 NOT NULL, PRIMARY KEY (`ID`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=380 ; this is the sql script of my table! and bild , bild2 , bild3 , bild4 have to be the file where the picture is saved! and my upload script looks like this: $_GET['kategorie']; echo '<h1>Anzeige einstellen</h1>'; echo '<form action="index.php?seite=artikeleinstellen2" enctype="multipart/form-data" method="POST"><br/>'; echo 'Kategorie:<br/>'; $ksql= "SELECT * FROM menu WHERE nebenkat=0"; $kresult = mysql_query($ksql); //SELECT START echo '<select name="kategorie">'; while ( $kat = mysql_fetch_array($kresult) ){ //Hauptkategorie echo '<optgroup label="'.$kat[3].'">'; $hk = $kat[1]; $uksql = "SELECT * FROM menu WHERE hauptkat=$hk AND nebenkat!=0"; $ukresult = mysql_query($uksql); while ( $u_kat = mysql_fetch_array($ukresult) ){ //Nebenkategorie echo '<option value="'.$u_kat[1].'-'.$u_kat[2].'">'.$u_kat[3].'</option>'; } echo '</optgroup>'; } echo '</select>'; //SELECT ENDE echo '<br/><br/>'; echo 'Zustand: '; echo '<select name="zustand">'; echo '<option value="Neu">Neu</option> <option value="Gebraucht">Gebraucht</option>'; echo '</select><br/><br/>'; echo 'Artikelname<br/>'; echo '<input type="text" size="50" maxlength="50" name="name" /><br/><br/>'; echo 'gewünschter Preis:<br/>'; echo '<input type="text" size="10" maxlength="20" name="preis" /> EURO<br><br>'; echo 'Bild 1*:<br/>'; echo '<input type="file" size="50" maxlength="150" name="bild1" /><br/>'; echo 'Bild 2*:<br/>'; echo '<input type="file" size="50" maxlength="150" name="bild2" /><br/>'; echo 'Bild 3*:<br/>'; echo '<input type="file" size="50" maxlength="150" name="bild3" /><br/>'; echo 'Bild 4*:<br/>'; echo '<input type="file" size="50" maxlength="150" name="bild4" /><br/>'; echo '<br/>'; echo 'genaue Beschreibung:<br/>'; echo '<textarea name="beschreibung" cols="50" rows="10"></textarea><br/>'; $zeit = time (); // Aktuelle Zeit in Sekunden $datum = getdate ( $zeit ); $date = $datum[0]; echo '<input name="date" value="'.$date.'" class="versteckt" /><br/>'; echo '<input type="submit" value="Artikel einstellen">'; echo '</form>'; this is the first part and the second part is like this: $eintrag = "INSERT INTO artikel (hauptkat, nebenkat, name, preis, beschreibung, date, user, zustand) VALUES ('$hkat', '$nkat', '$name', '$preis', '$beschreibung', '$date', '$user', '$zustand')"; and I know the comment to upload the picture its: move_uploaded_file but now I dont know how to deal with this! ok? Quote Link to comment https://forums.phpfreaks.com/topic/201840-upload-with-database/#findComment-1059113 Share on other sites More sharing options...
RichardRotterdam Posted May 16, 2010 Share Posted May 16, 2010 I'm guessing bild stands for image which i see 4 fields of. Where is the part where you handle the form when it has been submitted? And are you using $_FILES for this? Quote Link to comment https://forums.phpfreaks.com/topic/201840-upload-with-database/#findComment-1059121 Share on other sites More sharing options...
incorrect Posted May 16, 2010 Author Share Posted May 16, 2010 yes bild = picture and it right i have this 4 times! and i send it with $eintragen if i use $_FILES or not i dont know beacause i dont know how to use it xD i dont know how to save the file and give him a name! I know how to save the file in the database! you know what i mean? Quote Link to comment https://forums.phpfreaks.com/topic/201840-upload-with-database/#findComment-1059122 Share on other sites More sharing options...
incorrect Posted May 18, 2010 Author Share Posted May 18, 2010 Nobody is able to help me?? thats bad =( Quote Link to comment https://forums.phpfreaks.com/topic/201840-upload-with-database/#findComment-1060022 Share on other sites More sharing options...
RichardRotterdam Posted May 18, 2010 Share Posted May 18, 2010 if i use $_FILES or not i dont know beacause i dont know how to use it xD I find this sentence confusing do you or do you not use $_FILES ? If you don't know how to use it I suggest you check the manual with the link and maybe lookup some php file upload tutorials I know how to save the file in the database! you know what i mean? How do you mean that? can you elaborate? Quote Link to comment https://forums.phpfreaks.com/topic/201840-upload-with-database/#findComment-1060267 Share on other sites More sharing options...
incorrect Posted May 19, 2010 Author Share Posted May 19, 2010 ok sorry =) you told about upload tutorials! but i searched for some but don't find anything whats like the thnig i like to have =) so maybe you can post a link to a verry nice tutorial and i will check this =) ok? Quote Link to comment https://forums.phpfreaks.com/topic/201840-upload-with-database/#findComment-1060600 Share on other sites More sharing options...
RichardRotterdam Posted May 20, 2010 Share Posted May 20, 2010 Try to find tutorials that are about uploading the images to the server you can modify it later so it saves the image name to the database. There should be plenty of tutorials about this subject online even this forum has plenty of topics about it. Quote Link to comment https://forums.phpfreaks.com/topic/201840-upload-with-database/#findComment-1061048 Share on other sites More sharing options...
incorrect Posted May 20, 2010 Author Share Posted May 20, 2010 yes but i dont find anything where sb describes how to get the script uploading! but now im 2 weeks not online! So pls dont forget me =) if you can send me a link where i can find a tut it would be nice =) Quote Link to comment https://forums.phpfreaks.com/topic/201840-upload-with-database/#findComment-1061338 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.