Jump to content

premiso

Members
  • Posts

    6,951
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by premiso

  1. mysql_query(nquery); nquery should be $nquery
  2. mysql_fetch_assoc You have to retrieve the rows from the resource.
  3. Code it, google it or post in the freelance section. No one is going to do this, for free, for you.
  4. glob dir - check specifically in scandir You may also need fread or file
  5. Output buffering is the reasoning why. I believe you can set this in php.ini or in .htaccess. Either way, that is why it would work. The output was saved and displayed to the browser after processing. This is more of a bandaid to the issue, but yea.
  6. $string = "test.test.test.s"; $string = strstr($string, "."); echo $string; To remove the initial period you can make use of substr.
  7. Use preg_match and it can pull that data out. If there are multiples on the page preg_match_all
  8. Depends on what type of valuable data. It is safer then storing it as a cookie, but if it is very valuable you may be better of re-querying it when you need to.
  9. explode $string = "somestuff.otherstuff"; list(, $string) = explode(".", $string); echo $string;
  10. Understandable, but it all depends on the functionality. Like I said it will limit your functionality. Sort of, why even store it as BBCode in the database? Or why not just convert \n's to <br /> before entering into a DB? The reason being is you want it in it's raw format so you can manipulate it. Same rule applies here. That and the processing time really is not that much extra at all for the added functionality of the data stored in the DB. EDIT: And to be honest it is much more than 10 or 20 times. Depending on how many people view the site each day, it could be thousands. But I would still do it that way.
  11. As long as they are always <a href= a simple str_replace will work: $string = '<a href="http://www.site.com">Site.com</a>'; $string = str_replace('<a href="', '<a href="http://www.mysite.com/?url=', $string); echo $string;
  12. curl is another alternative.
  13. parse_url that should work for you.
  14. I would disagree, either way the processing is there. But storing it in it's raw form allows for any type of manipulation. That is just my 2cents though. Do it when it is coming out of the DB. Not going in. @OP, why it does not work I do not know, could be that you were double using it/using it wrong. It could also be that you put the link at the end IE: "This text link will not be processed http://www.link.com" because there is no ending space, as the regex uses the space to determine the end of a link. How to avoid this, I am not sure. You can always just append a space to the comment variable and that would solve that issue. Same if the link is at the beginning of the string. Like I said, not perfect
  15. <?php $string = "This should be converted to http://link.com www.link.com a link and http://www.link.com ok! and www.link.com "; $replace = array('~\shttp://(.+?)\s~', '~\swww\.(.+?)\s~'); $replaceWith = array(' <a href="http://$1">http://$1</a> ', ' <a href="http://www.$1">www.$1</a> '); $string = preg_replace($replace, $replaceWith, $string); echo $string; ?> Not perfect, but should work.
  16. It didn't work because you are not escaping a double quote in the link: <?php echo " | <a href=\"http://www.externallink.com\">External Link</a>"; ?> Or closing the ending quote. That should work.
  17. Javascript/AJAX is what you want to look into.
  18. So what is your question? What is the issue? What do you want from that? strtotime maybe that will help. Honestly provide us with more information, a description of what the problem is, and what you want the end result to be.
  19. Sort the field by userid, date in DESC order via the SQL query.
  20. <?php $writeTo = "<?php\n\$foo = \$bar;\n?>"; $fh = fopen('config.php', "w+"); fwrite($fh, $writeTo); fclose($fh); ?> Simple as that.
  21. Show the page where you set the actual session variable.
  22. ummm.....yes?
  23. Dangit, meant to do an edit. Please disregard my un-mindful clicking.
  24. Ok dude, look at what is changed. Here is the proper way to run your query. public function fetchArray() { // $this->fetchArray = mysql_fetch_assoc($this->query); No this is bad as it only gets 1 ROW. Note 1 ROW $this->numRows = mysql_num_rows($this->query); // check that we have rows returned. If not we are wasting time. if ($this->numRows < 1) { //Throw New Exception(mysql_error()); we do not want to throw the exception, cause any errors should be thrown via the query return array(); // instead return an empty array. Just because we did not get any rows returned, does not mean it is a bad query. }else { $array = array(); // instead of using $this->fetchArray, lets use $row as it may be easier to understand // that you are ITERATING (or moving) through each row that is returned. // Notice that each time the loop is ran it assigns a new row from the query to $row. // once all the rows have been iterated through, or looped through // mysql_fetch_assoc will return false thus $row is not set hence ending the loop. while ($row = mysql_fetch_assoc($query)) { $array[] = $row; // this stores the row in an array } return $array; } } Read the comments thoroughly to see why your logic is flawed and how you are using this completely wrong. Hopefully this helps you out.
×
×
  • 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.