|
|
|||||||||
|
|||||||||
|
|||||||||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
I do not know PHP nor do I see myself becoming a full fledge programmer anytime soon, but I am trying to follow along wiith this tutorial on adding blobs to a database:
http://www.devarticles.com/content....cleId=68&page=5 and I'm SOS = stuck on stupid... I'm trying to create a form that allows users to upload data or files to a table I've created in a database. The table contains the following fields: id author city state title copyright submitdate category filename filedata mediumblob filetype Can someone assist me in modifying this so that it allows the user to submit their data or upload a file, store that info into the database and then post it for public viewing in either a link or table format? These would be poems , essays, or short stories. Any help on this is appreciated. |
|
#2
|
|||
|
|||
|
makin a lil progress...
Man I'm burned out.OK...This is what I've come up with from my readings thus far. Again this is my first attempt at ever creating a database using mysql & php, so be king.
As a reminder I'm trying to allow users to submit files or text to a database to be made available for public viewing. I've created a submitform that has the fields I want stored. I've also created a database = dbnubiint and a table for this particular page = nuwoez. I've also created a user = dbnubiint_user. I take this code and add it to my submitform under <body> and get parse errors. The exact error is: Parse error: parse error, unexpected T_IF in c:\program files\php home edition 2\www\nuwoez\submitform.php on line 49. The Code: PHP Code:
My submitform contains both a file upload box and a textarea box. Not sure if this has anything to do with anything, just thought I'd post it. This is modified code from the Jokes database tutorial mysql.com. Again my hands on knowledge is entry level, so please don't assume I know what I'm doing. I appreciate any assistance I can get from the list. TIA * Edit: Please make use of the "php" and "/php" braces when displaying code. Last edited by FrankieShakes : September 17th, 2002 at 08:57 PM. |
|
#3
|
|||
|
|||
|
if dont know php, what the hell are you doing, blobing data isnt for begginners!
try reading this article for starters URL |
|
#4
|
|||
|
|||
|
Started out trying to follow the article here:
http://www.devarticles.com/content....cleId=68&page=3 Ended up up on an article located here: http://www.mysql.com/articles/ddws/23.html got spun around at about the 5 tutorial and have been dizzy ever since. I was hoping I could create a simple form, have users upload text or files from this form into a table in a database, and have that info made available for public viewing. It honeslty didn't seem like it would be this hard. Currently viewing this thread you just posted. Thanks |
|
#5
|
|||
|
|||
|
Okay,
The first problem I noticed is that when you store the values of "Filename" and "Filetype", you're not actually processing anything to retrieve the actual file information. I would suggest to check out this page of Mitch's tutorial, which explains how to store the actual file-type and filename values. Also, I would suggest changing the "CURDATE" to "CURDATE()" when inserting the date. Hope that helps, let us know...
__________________
____________________________________________ Developer Shed Weekly Writer | DevArticles Forum Moderator Build Your Own KlipFolio Klip With PHP FrankManno.com - Under Construction Design Interactive Group - Under Construction |
|
#6
|
|||
|
|||
|
as a genral tip, copy the article line for line, then modify the article database, to what you want, testing for problems as you go.
If your knowledge of php isnt that great, i suggest that you read lots of articles, from devarticles and also head down to your local book store and get some books on php |
|
#7
|
|||
|
|||
|
I think I've made some serious progress on this issue as I'm now able to connect to the db, submit the article and see it posted in the table in the db.
Can someone take a look at this page, click on submit writings, click the submit button, and then click the display button. I get an error that states the following: The query: SELECT * FROM nuwoez WHERE type='" did not return any data. This comes after trying to have it so that the submitted data shows up under the category that was selected. So if userA submits a poem and selects Poetry from the category list, the poem is stored under the Poetry list and userA can go to poertry, and poetry only, to view that poem. In other words, the submitted data goes to the category that was selected and can only be viewed in that category. Clicking one of the links in the menu to the left either displays that data or a link to that data. The way I have it set now, it displays the data. Here's the code from my displaycat.php file. <table width="100%"> <? require("conn.inc"); ?> <? $type = $_POST['type']; $sql = "SELECT * FROM nuwoez WHERE type='$type'"; $result = mysql_query($sql); $num_results = mysql_num_rows($result) or die ("The query: '$sql' did not return any data"); for ($i=0; $i<$num_results; $i++) { $row = mysql_fetch_row($result); $author = mysql_result($result, $i, "author"); $city = mysql_result($result, $i, "city"); $state = mysql_result($result, $i, "state"); $email = mysql_result($result, $i, "email"); $title = mysql_result($result, $i, "title"); $copyright = mysql_result($result, $i, "copyright"); $submitdate = mysql_result($result, $i, "submitdate"); $filename = mysql_result($result, $i, "filename"); $filedata = mysql_result($result, $i, "filedata"); echo "<tr bgcolor=white><td> </td>"; echo "<td>" . $author ."</td>"; echo "<td>".$city . "</td>"; echo "<td>".$state . "</td>"; echo "<td>".$email . "</td>"; echo "<td>".$title . "</td>"; echo "<td>".$copyright . "</td>"; echo "<td>".$submitdate . "</td>"; echo "<td>".$filename . "</td>"; echo "<td>".$filedata . "</td></tr>"; } ?> </table> I've tried and can't seem to get this $type variable to act right. Also can anyone tell me why my upload button doesn't seem to work? <TEXTAREA NAME="filedata" rows="20" cols="55" WRAP> </TEXTAREA><BR> <INPUT TYPE=SUBMIT NAME="Submit" VALUE="Submit"> <input type=reset name="clear" value="Clear"> </center><br> ANY help on this is appreciated. |
|
#8
|
|||
|
|||
|
I agree with Ben, if you are new to PHP do not start off with blobbing data into MySQL dbs as that's for programmers with intermediate experience with PHP. I would try working with some simple scripts trying to understand how they work before trying to blob data.
__________________
![]() ![]() "Only Linux users see the end of crashes." - Pl4t0 |
|
#9
|
||||
|
||||
|
Quote:
As ive said before, start with the basics and work your way up. You are obviously a begginner, and your tying to implement a script that that requires an intermediate knowledge of php. Im not trying to discourage you from trying, but i think from a professional programmers view that you should start learning the little things. Try what i said before, try the article without modifying it, you will get a better understanding. Quote:
If your only just found out how to connect to a database then i suggest that you read our mysql and php begginners article, which shows you the basics of mysql, then move on to blobing the file, i would suggest to you for the moment not to blob the file, but to store it in a dir. I hope that you take my advice otherwise your not going to get very far Regards Ben Rowe |
|
#10
|
|||
|
|||
|
My problem isn't connecting to the database as I'm familiar with that procedure. The problems comes afterwards and configuring php to do other things. Some articles say _POST and others say different. That's just something I'll have to learn as I go.
Though not a quitter in anything I choose to do, I do admit when I'm out of my league. I appreciate the advice and gracefully head to the back of the room where I sit with the online tuts, and my manual. I won't discontinue my efforts to resolve this issue I'll just ensure I have my *ish together before I post. Thanks again. Your responses are appreciated. |
|
#11
|
|||
|
|||
|
i would suggest coping the article, line for line, then slowly modify the code to your needs
|
|
#12
|
|||
|
|||
|
Quote:
Marv, The reason you see $_POST[] in a lot of the newer articles/tutorials is because of PHP's implementation of superglobals. Rather than referring to a variable the way you may be used to (ie: $userName) when calling another script, you now have to use PHP superglobal arrays (ie: $_POST['userName'] or $_GET['userName']). The difference between $_POST and $_GET depends on the "method" section of your "form" tag... If you use: <form method="post" action="callingScript.php"> Then you would use $_POST... If you prefer to use the superglobal arrays ($_POST, etc...), you'll need to turn "register_globals" to "off" in your PHP.INI file. For more information, check out the PHP manual. Hope that helps a bit... |
|
#13
|
|||
|
|||
|
also another tip is when you place a superglobal inside a string you need to encase it in curly brackets
eg $string = "my name is " . $_GET['name']; would become $string = "my name is {$_GET['name']}"; this is slightly faster, and most people still dont know about this |
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > Need help with php article and personal project... |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|