Jump to content


Staff Alumni
  • Posts

  • Joined

  • Last visited

  • Days Won


Everything posted by AbraCadaver

  1. $confirmation is a string and not an array at that point. If you did $confirmation[0] it would give you string offset 0 which is the first character of the string, but there is no redirect offset in a string.
  2. Another one: if(preg_grep("/$search/i", file("legitimatesites.txt"))) { echo "This website is an authorised distributor"; } elseif(preg_grep("/$search/i", file("illegitimatesites.txt"))) { echo "This website is NOT an authorised distributor"; } else { echo "Unknown website"; }
  3. First, clarify what "but it doesnt seem to work" means. Report any errors using: error_reporting(E_ALL); ini_set('display_errors', '1'); Also, no need to loop, you can use arrays in the str_ireplace: $haystack = file($file); /* put contents into an array */ $search = "$name, $sname"; /* value to be replaced */ $replace ="replaced, replaced"; /* value doing the replacing can be replaced by new variables*/ $haystack = str_ireplace($search, $replace, $haystack); /* case insensitive replacement */ But one problem is, what if $name and $sname are on different lines? No replacement is made. Maybe just use the file as a string: $haystack = file_get_contents($file); /* put contents into a string */ $search = "$name, $sname"; /* value to be replaced */ $replace ="replaced, replaced"; /* value doing the replacing can be replaced by new variables*/ $haystack = str_ireplace($search, $replace, $haystack); /* case insensitive replacement */
  4. You want to use the key from the foreach. Also you want to use !== false because it exists: foreach($scanned_directory as $key => $elements){ $pos = strpos($elements, 'thumbnail'); if($pos !== FALSE){ unset($scanned_directory[$key]); } } However this is much simpler (replaces all of your code): $files = preg_grep("/thumbnail/", glob("$var/*.*"), PREG_GREP_INVERT);
  5. For the original question, if you don't need the 1 or 0 for some other reason (or even if you do, just include both the column and the column case), do it in the query: SELECT column_name, CASE WHEN column_name IS 1 THEN 'Yes' ELSE 'No' END AS something FROM table_name Or: SELECT column_name, IF(column_name=1,'Yes','No') AS something FROM table_name For the fetch issue: $select_rma_detail->setFetchMode(PDO::FETCH_ASSOC);
  6. If you are instantiating an object of a class that contains those functions then upon calling set_FullName() if the if condition evaluates to true then the object var $this->FlagCount will be incremented 3 times. You haven't shown enough code or where you are attempting to see $this->FlagCount and it has not been incremented.
  7. This will never strips tags: $var = htmlentities($var); $var = strip_tags($var); Maybe reverse them.
  8. Though not the best solution, this should work: $newpost = str_replace("<div contenteditable=\"true\"><p>", "<p>", $post); $newpost = str_replace("<p>", "<div contenteditable=\"true\"><p>", $newpost); EDIT: Actually, your other idea should work: $newpost = str_replace("<p>", "<div contenteditable=\"true\"><p class=\"paragraph\">", $post);
  9. IPv6 enabled Windows, such as Windows 8 resolve localhost to an IPV6 address ::1. If your application is not IPV6 then the connection must timeout and then the IPV4 address is resolved and used.
  10. Where are you running out of memory? Building the $values array?
  11. $allusers = mysql_query("SELECT * FROM PMs WHERE `status`='0' AND ReceiveID='$myU->ID' ORDER BY ID"); if(!$allusers) { echo mysql_error(); } Just a guess but you'll probably need: ReceiveID='{$myU->ID}'
  12. If all you need is the count, here's one way: str_replace($needle, null, $result, $count); echo $count;
  13. No prob. I'm not a super OOP guy but I think the second way is the preferred method (dependency injection).
  14. private $_db; public function __construct() { $this->_db = mysql_init(); } Or pass it in: private $_db; public function __construct($db) { $this->_db = $db; } $db = mysql_init(); $note = new Note($db); Then anytime you need this in your class just use $this->_db
  15. = is for assignment. Try using == in the if statements. You could also use: <?php echo $_SESSION['sysadmin'] ? "YES" : "NO"; ?>
  16. Hmmm... Not very helpful but that's why I use Ubuntu. Debian only better, in my opinion.
  17. Probably need the glue for all of the pieces: apt-get install php5-mysql libapache2-mod-php5 libapache2-mod-php5 - Apache PHP module php5-mysql - MySQL extension for PHP (you'll need this when you try to use mysql in PHP :-) but try mysqli as that is what you should be using or PDO
  18. Wouldn't you learn more if you did your own homework?
  19. The foreach construct provides an easy way to iterate over arrays. http://us2.php.net/manual/en/control-structures.foreach.php It is iterating over each item in $this->productlist (which appear to be product objects) so that you can reference it as $product and do something with it. It appears that it is call the addstock() method on each object and adding 100 to the in stock quantity of each product, but we would need to see the addstock() function to tell.
  20. If you don't need the id I would just do: foreach($form['fields'] as $field) { $result[$field['label']] = $field['value']; } print_r($result);
  • 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.