Jump to content

premiso

Members
  • Posts

    6,951
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by premiso

  1. Will do. I'm beginning to think that the providers are identifying my mail as spam. The link below explains how PEAR can resolve the issue. http://www.webkami.com/programming/php/php-pear-mail-intro/sending-pear-mail-using-php-function-error.html I just don't like the idea of using huge copy and paste PHP scripts that I don't understand mostly because I don't kow how to begin editing them when I need to be specific. Should be plenty of examples using PEAR, but yea. If you want to understand it you can always look at the source code for it. Since it is open source.
  2. Well if you want the user to be able to create their own directory name, I would use REGEX to make sure that the name only contains valid characters. preg_match('/(^[a-z0-9]*)/i', $_POST['location'], $matches); if ($matches[1] != $_POST['location']) $error = "Location must contain only Aplha Numeric (abc123) characters."; That way they cannot have .. or / or ' etc in the dir name.
  3. Filter $_POST['location']. What is suppose to be passed to it/how should it be structured? Do you really need to send the dir location over post?
  4. $display = array(); while($bminfo = mysql_fetch_array( $data )) { //Displays the record $display[] = '<a href="'.$bminfo['linkurl'].'">'.$bminfo['linktitle'].'</a>';//Note two dots that i need to display } echo implode(" :: ", $display); } Should fix it.
  5. in a nutshell: <?php class db { private static $instance; private $cnx; static function getInstance(){ return self::$instance; } public function __construct ( $host, $user, $pass, $db ) { //Check for singleton if(self::$instance) throw new Exception("An instance already exists"); //Connect $this->cnx = mysql_connect($host,$user,$pass); mysql_select_db($db,$this->cnx); //Add singleton self::$instance = $this; } public function query ( $sql ) { } } //Connect $db1 = new db('host','user','pass','db'); //you can now use the variable $db1 as normal $db1->query(); //or get it via the static method $db2 = db::getInstance(); //or in a function function do_query ( ) { $db = db::getInstance(); } ?> be careful though, people tend to go crazy with singletons and use more memory then they need to Yea that is exactly what I would need. Be a bit easier than doing that global stuff. Thanks for the example. And yea I only see myself using singleton for the db connection. Thanks rhodesa.
  6. I will have to read up on that. If you want more in depth explanation post the code where you are using global at. Well I am working within Joomla (CMS) to build a custom component and within its backend they have a pre-built function that will do pagination for you and they set a global.. so I am using the code but not necessarily understanding why its being used... global $mainframe; $context = 'com_component.' . $d . '.list.'; $limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', 20, 'int' ); $limitstart = $mainframe->getUserStateFromRequest( $context.'limitstart', 'limitstart', 0, 'int' ); Just remember, because one script does it that way does not mean it is the correct way. Especially a script like Joomla where their ultimate goal is being able to use the script on any version of php etc. Not really a good script to learn OOP from imo.
  7. You can always look into PEAR::Mail or phpMailer, they seem to handle attachments very well.
  8. That stamp is part of a custom class. Not sure how $that is defined/used, maybe it should be $this instead? Unsure we need more code to help you.
  9. If you want more in depth explanation post the code where you are using global at.
  10. I setup my DB Class with functions, so it can be called from anywhere in my script without adding a ton of overhead. In these functions I make the instantiated db class global so I do not have to have that object to pass in each time I call it. That is a good way to use it, more for versatility. If you just have a regular variable say you want to add x + y, I would just pass both those in as parameters, as that is what the function is designed to do. So it all depends on the circumstance.
  11. For searching, it is usually a good idea to split the query into multiple parts and exclude common words like "the" "and" "or" etc. Your check input function is fine. But for the actual searching part I would do something like this: <?php function parse_query($query, $col) { if (strlen($query) < 3) return false; if (strstr($strng, " ") === false) return " $col LIKE '%" . check_input($string) . "%' "; $words = explode(" ", strtolower($string)); $statement = array(); $notAllowed = array("and", "the", "or"); // add more if you like foreach ($words as $word) { if (strlen($word) > 2 && !in_array($word, $notAllowed)) { $statement[] = " $col LIKE '%" . check_input($word) . "%' "; } } return implode(" OR ", $statement); } ?> Should put you on the right track. That way they are more like keywords and are more for searching. Questions let me know. The above is not tested.
  12. You need to use == not = in your if statements, and if Home is not a constant surround it in quotes.
  13. You need to mysql_fetch_row on the resource. Then access it by the index in the array [0]
  14. To add to this, use basename on the get data, to avoid them changing directories on you: <?php $page = basename($_GET['page']); if(file_exists($page.'.php')) { include($page.'.php'); } else { echo 'Page not found.'; } ?> That will be more secure.
  15. You are never resetting $s to equal "" $i = 10; while($i <= 50) { $s = ""; // reset $s switch($limit) { case "$i": $s = "SELECTED"; break; } echo '<option value="' . $i . '" ' . $s . '>' . $i . '</option>'; $i += 10; } echo '<option value="all" ' . $s . '>All</option>';
  16. Thanks for your interest. What I really want to know is when I put $count++ lower down it throws odd integers out. Why? Because it is essentially adding 2 every time to count, as you can see in the for loop count++ is already there, that works everytime, so when you add count++; inside the for loop it runs twice, thus giving you the odd integers. Make sense? It was like you were adding 2 each time the loop ran.
  17. SELECT SUM(friends_count) FROM tablename Should do it.
  18. Hey, what do I know? I have only been coding in PHP for the past 12 years. But in the very slight case I am wrong try this: function get_cookie() { if (isset($_COOKIE['uid'])) { $query = mysql_query("SELECT username FROM cookie WHERE uid = '{$_COOKIE['uid']}' LIMIT 1") or die('COOKIE UID:' . $_COOKIE['uid'] . ' SQL STATEMENT: ' . mysql_error()); $cookie = mysql_fetch_array($query); return $cookie['username']; } else { echo 'COOKIE UID Has not been set.'; return false; } } Give that a try and see what happens.
  19. if he did say index.php it would print out that full file, all the code. As long as you have an index.php. Give it a try.
  20. Is that the full code you are executing or is there more? If there is more post it, the 1 generally means a function returned true, so yea. Not sure if that is what is happening.
  21. Google AJAX/PHP namely jQuery. That would be the only way to do it. Not sure on the time but the progress bar. If you want time, maybe flash would work.
  22. if ($counter < $postcount) { echo '<li>' . $rp_date . ' - <a href="archive.php?link=' . $rp_data2 . '">' . $rp_data1 . '</a></li>'; } $counter++; Should do it.
  23. Because it is using get and you are adding it onto the url with the ?error= part. Store it in session and just redirect to the index.php usng $_SESSION instead of $_GET
  24. else { $fp = fopen($title,"a+"); }
  25. setcookie You are not using that function right. Set the other parameters. The domain should be .yourdomain.com path to / and time to however long you want the session to last.
×
×
  • 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.