Jump to content

premiso

Members
  • Posts

    6,951
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by premiso

  1. Is the br in there as [br] ? If so, this would work: <?php echo "<font face=verdana >"; $opFile = "blogfile.txt"; // Opens Blog File to read or dies $fp = fopen($opFile,"r") or die("Error Reading File"); $data = fread($fp, filesize($opFile)); fclose($fp); // Explodes data at line breaks $line = explode("\n", $data); $i=count($line); for ($n=0 ; $n < $i-1 ; $n++ ) { $blog = explode("|", $line[$n]); if (isset($blog[0])) { echo "name: " .$blog[0]."<br>"; echo " date: " .$blog[1]."<br>"; echo " subject: " .$blog[2]."<br>"; echo " message: " .str_replace("[br]", "<br />", $blog[3])."<br><br>";// changed this line here } } ?> I just wonder where/how it gets converted to a [ br]..as I do not see that in your code...
  2. How are you escaping the data going into the database? It sounds like you are adding too many slashes and thus the \n is being escaped so it displays it instead of parsing it. Just a question though, have you tried running the example you posted? Meaning bypassing the database?
  3. Shouldn't be that problem. Can you post the first few lines of your blogfile.txt inside the [ code] and [ /code] tags (without initial space) It could be that the \n's are throwing off the code and if I have it to test I can provide a more accurate response to the question.
  4. Scratch that update post.php and go back to your old one. Then use this to display the data. <?php echo "<font face=verdana >"; $opFile = "blogfile.txt"; // Opens Blog File to read or dies $fp = fopen($opFile,"r") or die("Error Reading File"); $data = fread($fp, filesize($opFile)); fclose($fp); // Explodes data at line breaks $line = explode("\n", $data); $i=count($line); for ($n=0 ; $n < $i-1 ; $n++ ) { $blog = explode("|", $line[$n]); if (isset($blog[0])) { echo "name: " .$blog[0]."<br>"; echo " date: " .$blog[1]."<br>"; echo " subject: " .$blog[2]."<br>"; echo " message: " .nl2br($blog[3])."<br><br>";// changed this line here } } ?> That should display it correctly with the brs in place.
  5. You would want to run an UPDATE not an insert: // Insert data $sql2="UPDATE user SET registered = '1'"; $result2=mysql_query($sql2) Make sure the register column is an int and if it is 0 the user is not registered if it is 1 the user is valid and allowed.
  6. Sort of, if your memory_limit is not set to handle a 40MB file. But the processing time on something like that is pretty massive. Especially when you are trying to insert the data into a database. This could take quite a while, I know with a 2mb file it takes a good deal of time. I cannot imagine it with a 40mb file. You may be better off using the CLI interface of PHP for running this script, so the browser etc does not time out. But the memory_limit may still hold you up so you may have to alter the php.ini and up that limit.
  7. Maybe I mis-interpreted it... Do you not want it to display as <br>? Instead you would rather it display as \n and you want the HTML to display it like it would display in notepad or another text-editing application? Can you provide an example of a post and how it displays then the same post with how it should display? I think that would help clear things up and help to get you the correct answer, cause I think you contradict yourself in your question, which is where my confusion is coming from.
  8. If I struggle to read the problem, I do not answer it. I cannot stand it when people use "u" instead of typing you. Text's I can understand, but come on. This is a forum where you have a full keyboard at your disposal. Learn to type please and stop abbreviating every little thing to save 2 characters. It annoys me, but I do not get angry. I see it as their loss, as if I have to struggle to read it then I do not answer, simple as that. As for proper grammar, that does not bother me cause I know I have horrible grammar, just as long as the words are actually typed out and spelled correctly, I could really care less if they forgot a comma or period. But I also understand that some people have poor education, are too young to know better or have a mental disorder like dyslexia that prevents them from fully understanding how to properly write out words etc correctly. Well yeah, that is my 2 cents. I feel bad for the ones for whom it is a mental disorder, and can understand that. But for someone who knows better, well yeah, that bugs me.
  9. Nope, good practice, no need to duplicate code when you can add it in one file and include it with other code that each page uses. I would however suggest: if($_SESSION) { To be a unique identifier such as "loggedin" if($_SESSION['loggedin']) { Just make sure to set that variable to be true when a user logs in.
  10. Then it is coming out of the DB it has a value of "" so the variable is created, meaning it was set, thus why you would need to check empty to check if that value has any data or not. You could even remove the isset if you wanted to and just check the empty.
  11. nl2br I believe is what you are looking for... <?php $filename = "blogfile.txt"; if (!isset($meddelande)) { $namn = $_POST['name']; //$date = $_POST['date']; $ämne = $_POST['subject']; $message = $_POST['message']; } $postdate = date('d M Y'); $blog = $name."|".$postdate."|".$subject."|".nl2br($message)."|[end]\n" ; // line modified here. $data = fopen($filename, "a"); fwrite($data, $blog); fclose($data); echo "message sent"; ?>
  12. By extension he means the php extension which is like an addon to say to the php language. You can input a file named anything as long as it is xml, so you can try changing the filename, but yea chances are that won't help any.
  13. How is $dtypewc being populated? If it is from a form, chances are register_globals is on and I would suggest turning them off or coding like they are off. Basically register_globals converts and form/session/cookie data to an actual string. So a form with a field name of dtypewc will out populate $dtypewc, when you should do something like this to assign the variable... <?php $dtypewc = (isset($_REQUEST['dtypewc']) && !empty($_REQUEST['dtypewc']))?$_REQUEST['dtypewc']:false; ?> Then your if would be <?php $dtypewc = (isset($_REQUEST['dtypewc']) && !empty($_REQUEST['dtypewc']))?$_REQUEST['dtypewc']:null; if (!is_null($dtypewc)) { ?> <tr><td id='header'> Will Consider a <?php echo $dtypewc; ?>. </td></tr> <?php } ?> That is assuming that is what is happening.
  14. <?php if (isset($dtypewc) && !empty($dtypewc)) { ?> <tr><td id='header'> Will Consider a <?php echo $dtypewc; ?>. </td></tr> <?php } ?> empty
  15. You will have to write the if statement one way or the other. There is no avoiding that. Using my first method, however, you could do this: <?php $selected = str_replace(".php", "", $_SERVER['PHP_SELF']); // now you should have "home" in there $pages[$selected] = 'class="current"'; echo' <div id="menu"> <ul id="si-menu"> <li><a href="index.php" title="Home" '.$pages['home'].'>Home</a></li> <li><a href="login.php" title="Login" '.$pages['login'].'>Login</a></li> <li><a href="register.php" title="Register" '.$pages['register'].'>Register</a></li> </ul> </div>'; ?> To avoid the notice errors, if you want to, do this. <?php $pages = array("home" => "", "login" => "", "register" => ""); $selected = str_replace(".php", "", strtolower($_SERVER['PHP_SELF'])); $pages[$selected] = 'class="current"'; echo' <div id="menu"> <ul id="si-menu"> <li><a href="index.php" title="Home" '.$pages['home'].'>Home</a></li> <li><a href="login.php" title="Login" '.$pages['login'].'>Login</a></li> <li><a href="register.php" title="Register" '.$pages['register'].'>Register</a></li> </ul> </div>'; ?> That should work without the if statement.
  16. Well a loop of 10 would not really show this. It works in Firefox cause that is what I use and I know it works...try this. <?php set_time_limit(100); for($i=0;$i<=10;$i++){ echo 'this is something '.$i; ob_flush(); flush(); sleep(5); } ?> It should take display that every 5 seconds. Along with the browser difference, I know that some Anti-virus software will hold your page buffer until the end then display it, so that is also something to think about/check.
  17. Or put that into an included file and just include that file... pageChange.php <?php if($page == "register"){ $reg = 'class="current"'; }elseif($page == "home"){ $home = 'class="current"'; }// etcc.... ?> home.php <?php include('pageChange.php'); echo' <div id="menu"> <ul id="si-menu"> <li><a href="index.php" title="Home" '.$home.'>Home</a></li> <li><a href="login.php" title="Login" '.$log.'>Login</a></li> <li><a href="register.php" title="Register" '.$reg.'>Register</a></li> </ul> </div>'; ?> Should work.
  18. Only works on some browsers <?php for($i=0;$i<=10;$i++){ echo 'this is something '.$i; ob_flush(); flush(); } ?> ob_flush and flush
  19. strtotime then date or explode $date = "01/01/2009"; $date = explode("/", $date); $newDate = $date[2] . "-" . $date[1] . "-" . $date[0]; $date = "01/01/2009"; $date = strtotime($date); $newDate = date('Y-m-d', $date); echo $newDate;
  20. WHERE destination LIKE '%$where%' OR duration LIKE '%$stay%' Or keyword in the WHERE clause if you want either or AND if you want both to be true.... WHERE destination LIKE '%$where%' AND duration LIKE '%$stay%'
  21. mail()
  22. mssql_get_last_message if(!@mssql('server','username','password')){ @mail('youremail@host.com','Site Problem','The MSSQL Server is Down Error:' . mssql_get_last_message()); die("The site is down for maintenance. Please visit back soon."); } I think that would work.
  23. Also, if you do not have php 5 or would prefer not to use try/catch (no reason not to imo but yea) set_error_handler PHP has a way for you to define your own way to handle php errors. But as stated, the try/catch is much easier and much less of a chance for an infinite loop =)
  24. Umm look at Joomla's forums, chances are someone already created a mod/hack for it. 2nd post in the right forum, this is a Third Party Script question. My 2 cents it is already done and looking at joomla forums you can find your answer.
×
×
  • 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.