Jump to content

senatorslab

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

senatorslab's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. holy crap. i've been staring at this forever trying to step through and see what was missing. i can't believe i didn't see that. well, at least i just have shitty eyes...lol. and not a complete fool. thanks again for all your help. i'll most definitely have to keep coming to this site to learn more. many regards. -senatorslab
  2. wow! that is awesome. i totally understand what is going on, but you are correct in saying there may be syntax errors. i keep getting Parse error: syntax error, unexpected ';' on the return(array) line. :( i can't see what is wrong immediately and i understand if you don't want to bother helping find a silly syntax error for me, so i'll get it eventually...i hope..lol. thanks SO much! you have enlighten me greatly to arrays and the implode function. thanks a lot for helping me out and for being so prompt about it as well. :)
  3. so i searched everywhere to try and get a solution to this, but searching for anything involving the word "errors" brings back all sorts of stuff (as expected... :() not relevant to my situation, and i apologize if this type of issue has already been covered. ok, i'm writing a page for a "content management system" that is used to update a "news scroller". the news scroller is done in flash as dynamic text that pulls from a flat text file. so with the CMS i am just writing to 5 text files. really simple. it's just 5 text input fields that are populated by the text files, and you can edit the input and then hit the submit to update all or some of the txt files. it all works fine, but i am trying to get some "validation" after the submission of updating the text files. simply put, i just want to echo certain variables based upon whether the text file was written correctly or not. i hope that is explained well. also, i'm sure there is a simpler way that i am trying to go about it, (i.e. using arrays to hold errors/successes perhaps??, maybe a case situation??, maybe something i don't even know??? lol) but if you would rather just help with the current method of multiple variables, that's fine. so with out further delay i'll get to the code. <?php function updatenews(){ $error1 = ""; $error2 = ""; $error3 = ""; $error4 = ""; $error5 = ""; $success1 = ""; $success2 = ""; $success3 = ""; $success4 = ""; $success5 = ""; $errors = ""; $successes = ""; $fn = "../news1.txt"; $fp = fopen($fn, "w"); if (!$fp){ $error1 = "Unable to open file: <b>news1.txt</b> for writing.<br>"; return $error1; }else { $news1 = stripslashes($_POST['news1']); fwrite($fp, "$news1"); fclose($fp); $success1 = "File: <b>news1.txt</b> written successfully.<br>"; return $success1; } $fn = "../news2.txt"; $fp = fopen($fn, "w"); if (!$fp){ $error2 = "Unable to open file: <b>news2.txt</b> for writing.<br>"; return $error2; }else { $news2 = stripslashes($_POST['news2']); fwrite($fp, "$news2"); fclose($fp); $success2 = "File: <b>news2.txt</b> written successfully.<br>"; return $success2; } //.....for simplicity (and a shorter post) i won't list the rest of the txt //files...just assume that i continue the above methodology for news 3, 4, and 5. } $errors = "$error1 $error2 $error3 $error4 $error5"; if($_POST["submit"]=="Update News"){ $errors = updatenews($_POST); if ($errors == "") $successes = "$success1 $success2 $success3 $success4 $success5"; } ?> and then in the html i am simply echoing the variables in a div like this: <div id="edit_news_error"> <?php echo $errors; ?> <?php echo $successes; ?> </div> what it currently does upon success is show the first success only ($success1) in my div and current layout is fine. and if i remove all of the news*.txt files to get the errors, it only displays the first error ($error1) and it doesn't display in my div at all correctly. the div layout issue is proly nothing, i'll most likely get it figured out when i get the error handling working right. hope this all makes sense to anyone that is willing to help. i will greatly appreciate it. i hope i have posted i the correct location and have abided by forum rules. if this needs to be moved to another location, i understand and apologize. thanks in advance. -senatorslab
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.