| We hope you enjoy your visit. You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free. Join our community! If you're already a member please log in to your account to access all of our features: |
| PHP Writing; An Article Script | |
|---|---|
| Tweet Topic Started: Jun 29 2005, 05:47 PM (1,268 Views) | |
| shockwave- | Jun 29 2005, 05:47 PM Post #1 |
|
My other title is a Ferrari
![]() ![]() ![]() ![]()
|
I've got a script that I'm writing, and it's supposed to write a news article to a file in the root directory, news.php. You can probably tell I'm new to PHP. I did some looking around, and here's the script I put together:
The problem is, it won't write to ../news.php! Someone, please help ![]() EDIT: Oh, and everything is CHMODDED correctly |
![]() |
|
| Das | Jun 29 2005, 05:52 PM Post #2 |
![]()
Smells of rich mahogany
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
Not 110% sure, but change:
To (try first):
Or (try if nessasary):
|
![]() |
|
| shockwave- | Jun 29 2005, 05:56 PM Post #3 |
|
My other title is a Ferrari
![]() ![]() ![]() ![]()
|
I get errors using both.
|
![]() |
|
| JoeC | Jun 29 2005, 06:28 PM Post #4 |
|
Euch! IE tastes horrible!
![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
May work. However, in the code, all this block of PHP is going into the form action...are you sure you want it to go here, and not somewhere else? |
![]() |
|
| shockwave- | Jun 29 2005, 06:35 PM Post #5 |
|
My other title is a Ferrari
![]() ![]() ![]() ![]()
|
Nope, Doesn't work. I put it in the form action, because I think that's what I'm supposed to do, but I wouldn't really know. However, when I was messing with the script, I did manage to create a file called $writefile (I screwed up variables and quotes). EDIT: I thought I just did it, but it only writes a colon
|
![]() |
|
| JoeC | Jun 29 2005, 07:52 PM Post #6 |
|
Euch! IE tastes horrible!
![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
Well, the action of a form is the location of the script that runs when the form is submitted. Example:
Would run the code in search.php when the form is submitted. |
![]() |
|
| bag | Jun 29 2005, 07:57 PM Post #7 |
|
Take Me To Your Larder
![]() ![]() ![]()
|
ok, just as a question, im confused as how the action html tag is supposed to run the script seeing as all php geniratres before the page even loads, so no data would therefor throw up errors. the action should be set to a page, wich holds the php prossor sperpetly? so youd have
then prossor.php where the forms sent to
i commented out teh bit that confused me (i did it in a bit of a rush, so not sure it will work. or i did everything 100%, but i *think* it may) |
![]() |
|
| Sani | Jun 29 2005, 07:59 PM Post #8 |
|
Member
![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
Try this, it could work, i have not tested it..
|
![]() |
|
| shockwave- | Jun 29 2005, 08:26 PM Post #9 |
|
My other title is a Ferrari
![]() ![]() ![]() ![]()
|
Ok, everyone! I Managed to do this :
The includecss part is just for formatting the article(s). Anyways, I managed to get it to work, and everything, and a few adjustments (like date posting), but I'm still having 2 problems (that I suspect are related to eachother) 1. When I visit the page to add a new article, the old one gets deleted, leaving just a colon! 2. I can only have one at a time, how would I put the next article on top of the last (descending order by date)? If anyone could help, that'd be great
|
![]() |
|
| solinent | Jun 29 2005, 08:44 PM Post #10 |
|
Member
![]() ![]() ![]() ![]() ![]()
|
This might not be fully parsed and good, but it should work(I haven't tried it, I using asp principals though)
I changed what's in red. Basicly what I changed is that it won't execute unless there is a title, so that it won't replace the old file whenever you access this page, and that it will name the new article depending on the name of the article. You should make it so that it replaces all spaces with underscores(I don't remember which function does this but...) It *should* work. |
![]() |
|
| Sani | Jun 29 2005, 08:45 PM Post #11 |
|
Member
![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
Why don't you read the contents of the entire file, and then place the entry before it? eg; Code from my old guestbook.. I think you can get the idea.. ![]()
|
![]() |
|
| shockwave- | Jun 29 2005, 09:01 PM Post #12 |
|
My other title is a Ferrari
![]() ![]() ![]() ![]()
|
You forgot to add the ending parenthases
Anyways, I was looking for it to write the article to ../news.php, not to seperate files. Although, now that I think of it, I think I should edit the script so on ../news.php, each article has a 200 charachter limit, then it links to the article's full page I'm gonna try it out. How would I count the characters inputed in a textarea, after submission? |
![]() |
|
| 1 user reading this topic (1 Guest and 0 Anonymous) | |
| « Previous Topic · Technology Chat · Next Topic » |
| Track Topic · E-mail Topic |
5:32 PM Jul 11
|



![]](../../../../0/1/0/p601690/pipright.png)





:
5:32 PM Jul 11