premiso
Members-
Posts
6,951 -
Joined
-
Last visited
-
Days Won
2
Everything posted by premiso
-
[SOLVED] Whats up with the return of this query?
premiso replied to mike12255's topic in PHP Coding Help
mysql_query(nquery); nquery should be $nquery -
[SOLVED] Whats up with the return of this query?
premiso replied to mike12255's topic in PHP Coding Help
mysql_fetch_assoc You have to retrieve the rows from the resource. -
glob dir - check specifically in scandir You may also need fread or file
-
[SOLVED] Warning: Cannot modify header information
premiso replied to jaikob's topic in PHP Coding Help
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. -
$string = "test.test.test.s"; $string = strstr($string, "."); echo $string; To remove the initial period you can make use of substr.
-
Use preg_match and it can pull that data out. If there are multiples on the page preg_match_all
-
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.
-
explode $string = "somestuff.otherstuff"; list(, $string) = explode(".", $string); echo $string;
-
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.
-
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;
-
curl is another alternative.
-
[SOLVED] You guys are gonna find this one easy!
premiso replied to ghostwalkz's topic in PHP Coding Help
parse_url that should work for you. -
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
-
<?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.
-
probably a realllllly easy question but...
premiso replied to chrishide87's topic in PHP Coding Help
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. -
Javascript/AJAX is what you want to look into.
-
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.
-
Sort the field by userid, date in DESC order via the SQL query.
-
<?php $writeTo = "<?php\n\$foo = \$bar;\n?>"; $fh = fopen('config.php', "w+"); fwrite($fh, $writeTo); fclose($fh); ?> Simple as that.
-
Show the page where you set the actual session variable.
-
[SOLVED] Allowed memory size of x bytes exhausted
premiso replied to 9three's topic in PHP Coding Help
Dangit, meant to do an edit. Please disregard my un-mindful clicking. -
[SOLVED] Allowed memory size of x bytes exhausted
premiso replied to 9three's topic in PHP Coding Help
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.