Reviews, updates and in depth guides to your favourite mobile games - AppGamer.com
|
|
Advanced PHP FILE NEWS SYSTEM QUESTION |
Page: 1 2 3 | Reply |
Sep 14th 2002 | #69290 Report |
Member since: Apr 12th 2002 Posts: 48 |
YO all i have a very advanced problem with php.....Im trying to do one of those form news things were u can fill out a form and it edits a txt file that is included on the index page...the form part is ok,so is the text file,and so is the main page that uses the include function to import the txt filee into it. my only problem is the php document that opens and edits the txt file and then closes it with the form info that i typed in.i will supply the source for all 4 pages and can u please try to explain how i can get the php part to work with the other pages.... Form File Named: newsform.htm [PHP] News Form:[/PHP] PHP FILE NAMED: news.php [PHP]$fp = fopen("news.txt","r+"); $what = fgets($fp); $what = array( echo ($head); ?> echo ($date); ?> echo ($news); ) rewind($fp); fputs($fp,$what); flock($fp,3); fclose($fp); ?>[/PHP] btw im pretty sure that this php file is the messed up file :mad: TEXT FILE : named news.txt there is no data in here yet because the php should edit the file and print in there what ever i entered into the form MAIN PAGE NAMED: home.php [PHP]include("http://localhost/news.txt") ?>[/PHP] the link does nt matter that is just were i placed the txt file in my server...... well i think that this must be the most difficult question i have asked here before and i hope it will be answered....i found out this could be done when i learned of the php counters that u can make without mysql but just a file that is edited and then closed whenever its accesed.......still the same theory....plz help me fix this php file and if u have more questions that u need answered to fix this prob email me at [EMAIL=micro@rant-on.net]micro@rant-on.net[/EMAIL] |
Reply with Quote Reply |
Sep 15th 2002 | #69294 Report |
Member since: Apr 12th 2002 Posts: 48 |
save me Hunkorama417 and sidex.....
|
Reply with Quote Reply |
Sep 15th 2002 | #69315 Report |
Member since: Apr 1st 2002 Posts: 1487 |
hey, what about me? :p anyway, i fixed the code up, and am just going to post 'em, hopefully you can see your own mistakes. news.php [PHP] $fp = fopen("news.txt","r+"); $news_entry = $head."\t".$date."\t".$news; fwrite($fp,$news_entry); fclose($fp); ?> [/PHP] newsform.html [PHP] News Form:[/PHP] home.php stays the same hope this is what you wanted. |
Reply with Quote Reply |
Sep 15th 2002 | #69350 Report |
Member since: Apr 12th 2002 Posts: 48 |
hey thanks man but shouldnt i have the $ sign in front of the names of the varibles.....?in the form part
|
Reply with Quote Reply |
Sep 15th 2002 | #69351 Report |
Member since: Apr 12th 2002 Posts: 48 |
:( :(
|
Reply with Quote Reply |
Sep 15th 2002 | #69352 Report |
Member since: Apr 12th 2002 Posts: 48 |
shouldnt it be like this and named a php file because the varibles are not being defined..... [PHP][/PHP] when i tested it in browser the thing says Notice: Undefined variable: head in c:\program files\apache group\apache\htdocs\news.php on line 3 Notice: Undefined variable: date in c:\program files\apache group\apache\htdocs\news.php on line 3 Notice: Undefined variable: news in c:\program files\apache group\apache\htdocs\news.php on line 3 nothing was wrong with the form but news.php couldnt find the varibles...so i added the $sign and turned it into a php document but now it says Parse error: parse error, unexpected '<' in c:\program files\apache group\apache\htdocs\newsform.php on line 2 the news.php works and im thankful for that but i still need to figure out the form part..... |
Reply with Quote Reply |
Sep 15th 2002 | #69357 Report |
Member since: Mar 20th 2001 Posts: 3367 |
You don't need to define variables in php. Its not like C++ or Java. Its just needs to be <input type="text" name="head" value="Header" maxlength="200" size="50"> When you parse the form, php takes the names as the variables and uses them. What P.Squid gave you was right. Some stuff might not work on the Windows side, so you might want to upload it to a Unix server and test it out. |
Reply with Quote Reply |
Sep 15th 2002 | #69366 Report |
Member since: Apr 12th 2002 Posts: 48 |
ok thanks
|
Reply with Quote Reply |
Sep 15th 2002 | #69368 Report |
Member since: Apr 12th 2002 Posts: 48 |
still there is an error on news.php [PHP]$fp = fopen("news.txt","r+"); $news_entry = $head."\t".$date."\t".$news; fwrite($fp,$news_entry); fclose($fp); ?> [/PHP] there is an error on line 4 |
Reply with Quote Reply |
Sep 15th 2002 | #69378 Report |
Member since: Mar 20th 2001 Posts: 3367 |
Try fwrite($fp, "$news_entry");
|
Reply with Quote Reply |
Page: 1 2 3 | Back to top |
Please login or register above to post in this forum |
© Web Media Network Limited. All rights reserved. No part of this website may be reproduced without written permission. Photoshop is a registered trademark of Adobe Inc.. TeamPhotoshop.com is not associated in any way with Adobe, nor is an offical Photoshop website. |