Jump to content

boby

Members
  • Posts

    25
  • Joined

  • Last visited

About boby

  • Birthday January 1

Profile Information

  • Gender
    Male

boby's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hello guys! I have a probably simple question for you... Let's say I have these two classes: class core { function core() { //do stuff here } } class parser extends core { function parser() { //do other stuff here } } Can I somehow tell the "core" class when it runs the constructor to load inside it (parent) all available extender classes? So if someone writes a new class to extend the "core" it should be automatically loaded, without needing me to load it in the constructor of the parent or to initialize with: $sub = new $subclassX; I am looking into something like adding a few classes that I need into the "core" class, but more if I have let's say a function "getID()" in the "core" and someone wants to use a different method, to easy load a new class with a new function that will do it the new way. Is this possible? Thank you for any help. Boby
  2. Thank you very much guys! I'll go with the switch
  3. I never had success using transparent PNGs in CSS, either use them as <img> tag in your HTML and a Javascript to make transparency (not the best method but anyway) or use transparent GIFs in your CSS.
  4. Hello guys! I am working on a script and asking myself which way to go. The script is for adding a new entry to the DB or editing an existing entry. Some of the fields are the same, but I cannot populate the fields that I use to add/edit an entry at the top and then populate if user is editing or if adding new. So, I am now asking what would be better, many IF clauses or a SWITCH? ...do common stuff... if ($action == 'edit') ...do edit stuff... ...do common stuff... if ($action == 'edit') ...do edit stuff... ...do common stuff... if ($action == 'new') ...do new entry stuff... or use the SWITCH like: switch (action) { case 'edit' : ...do edit stuff... ...do common stuff... ...do common stuff... ...do edit stuff... break; case 'new' : ...do common stuff... ...do common stuff... break; } If I choose the IF clause, the whole code is here and there. With the switch it would be more structured but I would have some things to write twice once for edit and the same in the new entry case. Thanks for any help! Regards, Boby Later Edit: Or should I use two different files? Here I would have again the same thing, both would have part of the code identical.
  5. Hello, I've been working on a search function for a while now and have seen some MySQL installations where boolean searches can not be performed even according to the MySQL version this should be no problem. Can anyone tell me how can I check if the server supports boolean searches? Right now I am checking against MySQL version, but it seems it's not enough: $booleanSearch = version_compare (mysql_get_server_info(), '4.0.1', '>=') == 1; Thank you for any help! Boby
  6. Hello guys, I am looking for a simple way to replace some paging links on a script, but I have a problem that sometimes the regex matches more than I need. Basically, I need to replace/remove all page 1 links, but it removes also pages starting with 1, for example page 11, 12, 13, 115, etc. I also don't know, if the paging variables are passed via URL with "[color=red]?[/color]" or "[color=red]&[/color]" or escaped as "[color=red]&a[i]m[/i]p;[/color]" I am using this code: [code=PHP]<?php   preg_replace (array ('#?p=1#i', '#&p=1#i', '#&amp;p=1#i'), '', $source); ?>[/code] My question is now, how to write te regexp to not include for matching if another numeric value is after the "1" because it now removes also ?p=12 or &p=13 and I don't want that. Can it be done without adding to the regexp all possibilities like line end after 1, or another "&" and then replace the &p=1& with &? I know this should be done in the paging function, but I don't want to alter the plugin because some are using it as is and not all will have this page 1 removed. Thank you very much.
  7. You can use [url=http://www.php.net/manual/en/function.preg-replace.php]preg_replace[/url] to replace all occurences of "," with "." Here is a little example: [code=php]<?php //Your lap time, get it from DB or whatever $time = '0:51,96 lap time'; //Remplace "," (comma) with "." (dot) //Multiple commas are trimmed down to one dot $time = preg_replace ('#,+#', '.', $time); echo $time; ?>[/code] I hope this is what you're looking for. BTW, the above will replace multiple commas with just one dot. [b]0:51,,,,,,,,,,,,96 lap time[/b] will result [b]0:51.96 lap time[/b] Boby
  8. I voted for SMF, I like it over all free forum softwares. Another nice forum software is [url=http://getvanilla.com/]Vanilla[/url], it doesn't have many out-of-box features, but there are a lot of plugins.
  9. I vote for vBulletin! It's just a matter of like or don't like. For example I like vBulleting (paid) and SMF (free) but I don't like IPB (paid) and phpBB (free). However I must admit, in my opinion vBulleting is the strongest Forum software. Some may disagree, but this is just my opinion.
  10. [url=http://www.php.net/manual/en/function.ereg-replace.php]ereg_replace[/url] = [i]Replace regular expression[/i] [url=http://www.php.net/manual/en/function.str-replace.php]str_replace[/url] = [i]Replace all occurrences of the search string with the replacement string[/i] If you know the exact submit messages (strings), I suggest to use [i]str_replace[/i], but if you need regular expression to determine messages, go for [url=http://www.php.net/manual/en/function.preg-replace.php]preg_replace[/url] instead of [i]ereg_replace[/i]. Boby
  11. Here is a more detailed example of what you are (hopefully) looking for: [code=PHP]<?php ... //Define your search keyword(s) $search = 'eggs'; //Escape special chars for use in a SQL statement $search_word = mysql_real_escape_string ($search); //Build SQL query $sql = "SELECT SQL_CALC_FOUND_ROWS * FROM `db_table` WHERE `field_1` LIKE '%{$search_word}%' OR `field_2` LIKE '%{$search_word}%' OR `field_3` LIKE '%{$search_word}%'"; //Run SQL query $result = mysql_query ($sql); //Check if query was successfull if (!$result) {   echo "Could not successfully run query ({$sql}) from DB: " . mysql_error();   exit; } //Get number of found rows $count = mysql_fetch_assoc (mysql_query ('SELECT FOUND_ROWS() as `total`')); //Check if we have results if ($count['total'] > 0) {   echo '<table>';   //Loop through each found row   while ($row = mysql_fetch_assoc ($result))   {       echo '<tr>               <td>'.$row['field_1'].'</td>               <td>'.$row['field_2'].'</td>               <td>'.$row['field_3'].'</td>             </tr>';   }   echo "</table>"; } else {   //No results found, display error msg   echo 'No results found!'; } ... ?>[/code] The use boolean search and fulltext fields like "[b]The Little Guy[/b]" suggested in the post above, you will need at least MySQL v4.0.1 to add fulltext indexes (since v3.23.23) and the boolean modifier available. I found out there are some providers that have it disabled for a reason or another. A boolean search will give you "better" results but usually less, I would use it over the regular search option. http://dev.mysql.com/doc/refman/4.1/en/fulltext-search.html Boby
  12. If you really want to use [b]str_replace[/b] then I suggest you replace also [b]\r[/b] and [b]\r\n[/b]. [code=PHP]$string = str_replace (array ("\r\n", "\n", "\r"), "<br />", $string);[/code] [b]nl2br[/b] will take care of all three ways. [b]\n[/b] = *Nix [b]\r[/b] = Windows [b]\r\n[/b] = Mac
  13. Make sure there is no output made before you send the redirect header or it won't work.
  14. Here is a more detailed example, make sure the SQL query is correct and I've also noticed you are using [b]$city[/b] but the variable was not assigned. Use [b]$row_rscontacts['db_table_field'][/b], in the  following example it's [b]$row_rscontacts['city'][/b]. [code=PHP]<?php //Build SQL query $sql = "SELECT `city` FROM `db_users`"; //Run SQL query $rscontacts = mysql_query ($sql); //Check if query was successfull if (!$rscontacts) {   echo "Could not successfully run query ({$sql}) from DB: " . mysql_error();   exit; } $str = "<?xml version='1.0'?>\n <properties>\n"; //Check if we have results if (mysql_num_rows ($rscontacts) > 0) {   //Loop through each found row   while ($row_rscontacts = mysql_fetch_assoc ($rscontacts))   {       $str .= "\t<property>\n             \t\t<city>".$row_rscontacts['city']."</city>\n             \t</property>\n";   } } $str .= "</properties>"; ?>[/code]
  15. I use Quanta Plus mainly because I'm running Linux. Actually I like Zend Studio more than all the other I have tried, but unfortunately I cannot afford to buy a license yet. If I have to code something on Windows, I use PHP Designer. Boby
×
×
  • 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.