Reviews, updates and in depth guides to your favourite mobile games - AppGamer.com
|
|
Basic News system question |
Page: 1 2 | Reply |
Dec 14th 2003 | #133387 Report |
Member since: Jul 19th 2003 Posts: 810 |
So, Basically i have been learning/trying to learn a bit of PHP over the last few days. I came across a tutorial on codewlakers.com for a basic news system, anyways..... i followed the first part of the tutrorial and it all worked fine... but then, when i was trying to do the second part and i tested it i got Can anyone see why?? :: This is the code : [code] <FORM ACTION="<?=$PHP_SELF?>" METHOD="POST" NAME="newsentry"> Your name:<BR> <INPUT TYPE="text" SIZE="30" NAME="name"><BR> The News:<BR> <TEXTAREA NAME="news" COLS="40" ROWS="5"></TEXTAREA><BR><BR> News Password:<BR> <INPUT TYPE="password" SIZE="30" NAME="password"><BR> <INPUT TYPE="submit" NAME="submit" VALUE="Post it!"><BR> </FORM> [/code] Line 152 is the very bottom of that.... the code is just a snippet obviously.. Help please !!! |
Reply with Quote Reply |
Dec 14th 2003 | #133398 Report |
Member since: Nov 26th 2001 Posts: 2586 |
use the [ php ] [ / php ] tags so we can view your code =) Parse errors are parse errors. You have an error in your syntax. If you see the error line at the end of the code, it usually means you forgot like a closing bracket somewhere that wraps the entire script, for example. |
Reply with Quote Reply |
Dec 14th 2003 | #133402 Report |
Member since: Jul 19th 2003 Posts: 810 |
thanks..... i will put the proper code in...... shall i put the WHOLE code in or just the bit with the error? |
Reply with Quote Reply |
Dec 14th 2003 | #133410 Report |
Member since: May 18th 2003 Posts: 324 |
post the whole code at http://codedump.phpfreaks.com and then post the link here.
|
Reply with Quote Reply |
Dec 15th 2003 | #133445 Report |
Member since: Mar 29th 2003 Posts: 1326 |
Or just post the whole code here...I'm guessing its not that long... tom |
Reply with Quote Reply |
Dec 15th 2003 | #133479 Report |
Member since: Mar 20th 2001 Posts: 3367 |
Its most probably syntax error. I edited you post but there's only the form, nothing on the PHP code itself.
|
Reply with Quote Reply |
Dec 15th 2003 | #133513 Report |
Member since: Jul 19th 2003 Posts: 810 |
below as raw code : [php] echo " Current News\n";$data = file('news.txt'); foreach($data as $key=>$element) { $element = trim($element); $pieces = explode("|", $element); echo $pieces[2] . " " . "Posted by " . $pieces[1] . " on " . $pieces[0] . "\n"; echo " Delete\n"; echo " Edit\n"; echo " \n"; if($action == "delete" && isset($HTTP_POST_VARS['pass'])) { if($action == "delete") { echo " You are about to delete the following news item.\n";$data = file('news.txt'); $element = trim($data[$id]); $pieces = explode("|", $element); echo $pieces[2] . " " . "Posted by " . $pieces[1] . " on " . $pieces[0] . "\n"; echo " \n"; echo "Are you sure you want to delete this news item? If so, enter the password and click on Delete. \n"; echo "\n"; exit; } if($action == "delete" && isset($HTTP_POST_VARS['password'])) { if($HTTP_POST_VARS['password'] == "pass") { $data = file('news.txt'); array_splice($data,$id,1); $fp = fopen('news.txt','w'); foreach($data as $element) { fwrite($fp, $element); } fclose($fp); echo "Item deleted! \n"; echo "Go Back\n"; exit; } else { echo "Bad password!\n"; exit; } if($action == "edit") { $data = file('news.txt'); $element = trim($data[$id]); $pieces = explode("|", $element); $news = str_replace(" ","\r\n",$pieces[2]); echo "Make the changes you would like and press save. \n"; echo "\n"; exit; } if($action == "edit" && isset($HTTP_POST_VARS['password'])) { if($HTTP_POST_VARS['password'] == "pass") { $line = $HTTP_POST_VARS['date'] . "|" . $HTTP_POST_VARS['name']; $line .= "|" . $HTTP_POST_VARS['news']; $line = str_replace("\r\n"," ",$line); $line .= "\r\n"; $data = file('news.txt'); $data[$id] = $line; reset($data); $fp = fopen('news.txt','w'); foreach($data as $element) { fwrite($fp, $element); } fclose($fp); echo "Item Edited! \n"; echo "Go Back\n"; exit; } else { echo "Bad password!\n"; exit; } } echo " \n"; echo " Add News\n";if($HTTP_POST_VARS['submit']) { if($HTTP_POST_VARS['password'] == 'pass') { if(!$HTTP_POST_VARS['name']) { echo "You must enter a name"; exit; } if(!$HTTP_POST_VARS['news']) { echo "You must enter some news"; exit; } if(strstr($HTTP_POST_VARS['name'],"|")) { echo "Name cannot contain the pipe symbol - |"; exit; } if(strstr($HTTP_POST_VARS['news'],"|")) { echo "News cannot contain the pipe symbol - |"; exit; } $fp = fopen('news.txt','a'); if(!$fp) { echo "Error opening file!"; exit; } $line = date("m.d.y") . "|" . $HTTP_POST_VARS['name']; $line .= "|" . $HTTP_POST_VARS['news']; $line = str_replace("\r\n"," ",$line); $line .= "\r\n"; fwrite($fp, $line); if(!fclose($fp)) { echo "Error closing file!"; exit; } echo "News added!\n"; } else { echo "Bad Password"; } } ?> [/php] |
Reply with Quote Reply |
Dec 15th 2003 | #133520 Report |
Member since: Mar 20th 2001 Posts: 3367 |
Can't seem to figure it out. Only thing I can find is that you missed one closing "}" for the first if statement(if i read the code correctly)
|
Reply with Quote Reply |
Dec 15th 2003 | #133523 Report |
Member since: Jul 19th 2003 Posts: 810 |
So you are saying its should look like this : [PHP] if($action == "delete" && isset($HTTP_POST_VARS['pass'])) { if($action == "delete") { echo " You are about to delete the following news item.\n";}[/PHP] that right? |
Reply with Quote Reply |
Dec 15th 2003 | #133532 Report |
Member since: Jul 19th 2003 Posts: 810 |
|
Reply with Quote Reply |
Page: 1 2 | 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. |