Detect Phrase Being Repeated X Times In A Row?
Would somebody please tell me if there is a way to find out if something is repeated X times in a row in a string?
Like if X is 5 and the string is "Cows go moooooooo" then it would replace the "ooooo" after "m" with Y "o"s, like "oo" if Y=2?
Is this possible? And if it is could somebody please help me get started? I have no clue how to do this >_>
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Phrase Searching
there have been doing some reading online about search engines and site searches and stuff. I am interested in knowing if there are any good tutorials out there or anything that someone might know of that shows a good process for phrase searching on a database.
Repeated Filling
How do I fill up a form continously and submit it remotely? Meaning, the form info comes in from a dbase using php and gets submited to a remote site. All this happens automatically.
A Repeated Region Within A Repeated Region...
I am trying to list each client in my database. The loop begins with the Clients table and starts spitting out information about the client. Then the second loop begins. This loop goes through the Projects table and it is suppossed to count the number of projects that belong to each member. Instead of looping through the Projects table each time the Client's loop loops through and gets information for the next client, the Projects table is only looped through on the first run-through of the first client. Can someone tell me how I can get the loop to start at the beginning of the Projects table each time the Clients loop starts over? Code:
I'm Getting The Same Row Of Info Repeated
I need to access data from a database and repeat the display for how many rows there are...Well I figured out the whole repeat thing I just can't make it go to the next row when it outputs... Code:
Repeated Forced Download In IE
I find this a very strange problem. I'm trying to force a download of a file, by linking to a PHP script and sending out http headers. When I click on this link in IE more than 2 times, it just won't work anymore. This on itself is not much of a problem, but I want to give the user the opportunity to download more than one file, and if I try listing 5 links, I can only download 2, and the rest won't work anymore. Is this just a nasty IE bug or am I forgetting something? Here's the code that forces the file to download:
Make Link With A Phrase
I would like to have some help for this: There is any phrase like "Some text, here, #*$!, yyy aaaa" I need to separate the words and make links, like: <a href='Some'>Some</a> <a href='text'>text</a> <a href='here'>here</a> Someone know any topic that explain how to do that?
File Select On Server (repeated)
(repeated because I forget to add comp.lang.php to the list) I have an admin interface. I want the admin to be able to select an image file on the server and attach it to an email to be sent out to a user. If I use type="file", it puts up a browse on the user's machine. Is there a comparable thing for use on the server? I could always place these images into a special directory and then simply have them listed in a select list. However, i was wondering if this more general thing is available. Of course, I would ONLY use it in an admin situation.
PHP - Passing A Variable From A Repeated Region?
I have a repeated region with a 'Name' a 'ID' and a 'Submit' button Repeated Region ------------------------------------------------ {Recordset1.Name}, {Recordset1.ID} | SUBMIT | ------------------------------------------------ so on my page I see every name next to every ID in my database and each one has their own submit button. Now what I need to do is on Submit pass the specific ID of the row in the table for which the submit button was pressed. For example if they scroll down to the 5 element in the repeated region (with ID 5) and they hit Submit I need to pass the number 5 to a function. I understand that you cant call a php function from a button press so I have been trying to do this with the if(isset($_POST['submit'])) { // do whatever with the variable. } statement. Does anyone know how I can do this properly?
Offensive Word/phrase Filter
I've got a function that is being used to filter messages before they're inserted into a database that gets rid of any foul language and replaces it with either **** or an alternate word/phrase. The problem is it replaces parts of other words. For example, the word Assault gets replaced as: ***ault. Can someone please help me modify this so it only replaces whole words? I was thinking maybe putting spaces around the word to check it, but this will cause it to fail on words at the beginning of the text or with punctuation after or around the word (like "bleep" or bleep.) here's the function: Code:
Trim() A Phrase Instead Of Individual Characters
I have a script that takes a URL and trims characters from it for storage in a database. My intention is to trim http:// from the start of the URL and and trailing slashes. For this I have been using the following: $url = trim($url, "http://"); Unfortunately a problem has arisen in that any url's ending in .net have "t" trimmed from the end because, I realise, trim() strips out individual characters, not phrases. Is there any way trim() can be modified to only find and remove the instance of http:// in it's entirety, and ignore single instances of the letters, or is there an alternative function I should be looking at?
Select Specific Phrase From MYSQL Database
I am working on a World of Warcraft guild's website and I am trying to create a page where players can select different kinds of gear, i.e. the gear with the most Stamina. All the player's items are stored in the database and every item have a field in the Items-table containing the item's tooltip. This could look something like: Boots of the Nexus Warden Soulbound Feet Cloth 97 Armor +27 Stamina +17 Intellect Durability 35 / 35 Equip: Improves spell hit rating by 18. Equip: Increases damage and healing done by magical spells and effects by up to 21. I then want to select the item with i.e. the most Stamina for all the different slots; Head, Chest, Legs etc. If I write this: $query = mysql_query("SELECT substring(item_tooltip, LOCATE('Stamina', item_tooltip)) AS maxor FROM roster_items WHERE member_id = ེ'") or die(mysql_error()); It returns the following: Stamina +17 Intellect Durability 35 / 35 Equip: Improves spell hit rating by 18. Equip: Increases damage and healing done by magical spells and effects by up to 21. But I want for it to show the leading characters also (in this case "+27 " before "Stamina") and then not show anything else after the phrase "Stamina". So it shows "+27 Stamina" and nothing else for the above mentioned item. How do I accomplish this? And then, secondly how do I then get it to show only the item with the most Stamina after it selected the above? Hope this makes any sense. I've tried to search these forums and found something a little along the lines of my problem but haven't been able to adjust them to my needs and I therefore need your help which will be greatly appreciated.
Split By Spaces But Not When Phrase Is Inside Quotes...
I'm writing a function that parses a nested list string that might look like this: ( "HELLO WORLD!" 1231231 awesome ( 1 2 ) ) I wrote the logic already and it starts by splitting the string by the space character (or tab or newline). ex... $tklist = preg_split("/s| | /", $str); This works except in the string case, where "HELLO WORLD!" should not be two parts. How do I split by spaces but keep phrases inside quotes in tact? Is there an easy way to do this?
Times
I'm currently storing start and end times (hh:mm:ss) for shows in a radio schedule using MySQL and processing the data with PHP. I need to add one second to the end time to ensure it is formatted correctly (e.g. 09:29:59 to 9:30am) however I just cannot see how to do it *correctly* - with PHP or MySQL. I may well be overlooking something but I would be grateful if anybody could help and point me in the right direction.
Intersection Of 2 Times In Php
I have to do a script that calculates the intersection of 2 times. I write it in php instead of explaining: $time1_from = "2006-02-01 08:00"; $time1_to = "2006-02-01 20:00"; $time2_from = "2006-02-01 06:00"; $time2_to = "2006-02-01 18:00"; I want the script to calculate that there are 8 hours common in those two times. And the script should work for any 2 times. And of course, where there is no intersection, the return value should be 0.
Changing Between Times
does anyone know to convert a time string in the form dd-mm-yyyyThh:mm:ss i.e 2006-08-01T15:45:11-00:00 to a normal unix time stamp or something that at least I can use to compare to a unix timestamp.
Download Times
I need to count how many times a specific file has been downloaded. I dont know if this will happen on the client or server side.
Php Dates And Times
I have a mySQL database that contains a DATETIME type column. An example entry would be "2001-08-07 17:30:58". I've pulled that value out of the table and am storing in a variable called $endtime. I want to test $endtime and do one of two things. If the datetime in the variable has not yet arrived, I want to print the time remaining to the screen. If the datetime has arrived I want to do something to my table. It will look like this: if ($endtime has not arrived) { //echo "time remaining"; } else { //mysql operations}
Ftp_put Times Out
I've got a script which uploads a few files to a remote server. The problem is the ftp_put command hands and the script eventually times out. What is even more strange is sometime it works fine. When it's not working i've check the connectiion and done a manual upload with a proprietry ftp program and all is fine.
Ftp_put Times Out
I've got a script which uploads a few files to a remote server. The problem is the ftp_put command hands and the script eventually times out. What is even more strange is sometime it works fine. When it's not working i've check the connectiion and done a manual upload with a proprietry ftp program and all is fine.
How To Run PHP Script At Certain Times?
I am experimenting with web crawling and spidering and the spider script i have needs to be ran manually. how would i set it to run at certain times? automatically?
Dates/Times
I'm making a really basic forum. When users post I want it to say "Latest post: (TIME) (DATE)" in say 22:00, then date as DD/MM/YY When I insert it into the database do I want my field to be configured as "DATE" and a field configured as "TIME" or should I use VARCHAR? But I also noticed it doesn't insert it in DD/MM/YY, it does MM/DD/YY or something weird? To insert do I just do time() and date()?
Result Displays Seven Times In A Row
I'm trying to list out songs of a specific album and I think my code is fine. The only problem is that all the songs are displayed seven times. Everything else is fine.
A For Loop That Loops 1.5 Times
Below is some code from a page of mine that is supposed to process form data. The data is made up of checkboxes that a user randomly selects when they want to delete a file from a list of files. dbmysqlconnect_pgs(); for ($x = 0; $x <= count($checkbox); $x++) { $query2 = "SELECT name FROM proposalinfo WHERE propid='$propid' "; $results2 = mysql_query($query2) or die("Error in query 2"); while($query_data = mysql_fetch_array($results2)) { $name = $query_data["name"]; } $query4 = "SELECT filename FROM files WHERE fileid='$checkbox[$x]' AND propid='$propid' "; $results4 = mysql_query($query4) or die("Error in query 4"); while($query_data = mysql_fetch_array($results4)) { $filename = $query_data["filename"]; } //THIS IS WHERE THE ARCHIVE OF THE OLD FILE IS PROCESSED $query3 = "INSERT INTO archives (date, userid, propid, filename, fileid) VALUES (NOW(), '$userid', '$propid', '$filename', '$checkbox[$x]') "; $results3 = mysql_query($query3) or die("Error in query 3"); $query4 = "SELECT date FROM archives WHERE fileid='$checkbox[$x]' AND propid='$propid' "; $results4 = mysql_query($query4) or die("Error in query 4"); while($query_data = mysql_fetch_array($results4)) { $date = $query_data["date"]; } //THIS IS WHERE THE RENAME OF THE FILE IS PROCESSED $oldfilename=$filename; $oldname="./" . $name . "/" . $oldfilename; $newfilename=$oldfilename . $date; $newname="/overflow/pgs_archives/" . $name . "_archive/" . $newfilename; copy("$oldname", "$newname"); unlink("$oldname"); //THIS IS WHERE THE DELETE OF THE DB DATA IS PROCESSED $query5 = "DELETE FROM files WHERE fileid='$checkbox[$x]' AND propid='$propid' "; $results5 = mysql_query($query5) or die("Error in query 5"); $query6 = "DELETE FROM fileinfo WHERE fileid='$checkbox[$x]' "; $results6 = mysql_query($query6) or die("Error in query 6"); } indentheader(ཐ',ń',ཐ','header3','The selected files have been deleted from the system.'); The problem I am having is that this will only execute 1.5 times before failing. The failure is at query3. Basically if you selected two or more checkboxes you will only delete one of the entries. Query3 runs by itself just fine and works the first time. Anyone have any ideas?
Query (dates And Times)
Struggling with a query here. table name : holidays fields : holname (format varchar) holdate (format date 2004-01-01) The table is populated with all the holidays for the next 5 years. I am trying to select only 1 of each holiday for the current year, AND if todays date is past a holiday for the current year, then select the following years holiday. For example, today date would return easter, mothers day, etc. AND next years valentines (because it is past 2004-02-14). Does this make sense ?
Execution Times/Modules
I am encoutering the following performance problem with php 3.0.16, the latest apache, running with compiled in php_mod on a sun ultra1. i have written a set of php class files, which i use througout the site. the execution time of my skripts is very fast, but it seems that the class files i require (about 30k) slow down the performance enourmously. when i benchmark the site using ab with a php file which simply does html output and nothing else. its really fast, if i require my class files and do nothing else than the html output, the performance drops incredibly (no db connection, no computation, nothing) i always thought that php_mod also keeps a byte code for the required pages in memory (like for example perl_mod). but now i doubt that. it seems that every request, forces php_mod to reload and recompile (or totally interpret ?!?!??) every file needed. is there anyway to increase performance when using multiple phpclass files? I know of conditional includes, but thats IMHO not a pretty solution.
How Many Times A File Has Been Downloaded
I'm looking for some help on implementing a script that will keep track of how many times a specific IP address and/or user has downloaded a file. Any ideas where I can start this search?
Looping? Don't Know How Many Times Needed?
I want a page to print out a lineage table. So, I have the first dragon's mom ID and dad ID, and then I want it to print out that dragon's mother's mother ID and dad ID, and that dragon's mother's mother's mother ID and dad ID, and so on.
Run Code Every 3 Times In A While Loop
I need a certain block of code to run inside a while loop every 3 times its run but I cant figure out how to write it. I came up with a sort of static fix but I need it to be more expandable. Here is what I've got inside the loop so far. if ($num == 3 || $num == 6 || $num == 9 || $num == 12 || $num == 15 || $num == 18 || $num == 21 || $num == 24 ect...) { echo('</tr><tr>');} The loop output 3 profiles with images and names on each line and then goes to a new line for the next 3 using tables. Is there a way to write this so it runs every 3 on to infinity and not have to input the numbers manualy?
Number Of Times To Hit MySQL
Is it standard or unadvised to put a mysql entry into a loop where it could potentially loop a couple hundred times?
Using Same Recordset Multiple Times
I've created a recordset and want to use it to populate the contents of multiple drop-down menus. To do this once is easy enough, but the number of drop-down menus is created dynamically based on a number entered on a previous page. I've done a 'do while' loop to create all of the drop-downs, and nested another 'do while' loop inside the <SELECT> field to populate the contents from the recordset. However, only one drop-down menu populates, the others stay blank. I've run into similar problems before, and it seems that I can't use the same recordset more than once. Is that correct, or have I made a fundamental mistake? Code:
Repeat As Many Times As User Specify Then Stop
I'm trying to write a script that uses and tag called steps to creat a tutorial database. This is how it works. the user comes to the page and chooses how many steps are in there tutorial. The $steps are always resubmitted to the same page depending on how many steps the are part shown and the bottom repeats until it reaches that value. My Problem I don't know grab the value submitted and make it repeat til that value is match. <form name="form"> <select name="site" size=1 onChange="javascript:formHandler()"> <?php $count = 0; while($count <= 24) { $count++; echo "<option value="submittut.php?steps=$count"> $count</option>"; }; if ($steps != 0) ------------------------> Part 2 { echo "<br><br><table width="100%" border="0" cellspacing="1" cellpadding="1"> <tr> <td rowspan="2" valign="middle"><font size="+2"></font> </td> <td bgcolor="#cacaca"> <div align="center"> <b>Upload the corresponding picture here</b></div> </td> <td bgcolor="#cacaca"> <div align="center"> <b> Paste your the Text and HTML into the text are below</b></div> </td> </tr> <tr> <td valign="middle"> <div align="center"> <br> <input type="file" name="fileGetterName" size="26" border="0"></div> </td> <td> <div align="center"> <br> <textarea name="textareaName" rows="4" cols="40"></textarea></div> </td> </tr>"; } while () ?>
Script Executes Multiple Times?
I've got a file of code that is included in a page. I recently made a change to the code and now the script executes multiple times. In the main file, I've got this: if ( $_SERVER[SERVER_NAME] == "www.domain.com" ) { $pagename = 'index' $hitcount = 'X' include("include/userlog.php"); } In userlog.php, I've got this: $dt_logged = date("Y-n-j H:i:s"); $ip_addr = GetHostByName($REMOTE_ADDR); @ $db = mysql_pconnect("localhost", "x", "x"); if (!$db) { print 'Error: Could not connect to database. Please try again later.' exit; } mysql_select_db("dbname"); $insert_query = "insert into tablename values ('".$dt_logged."', '".$ip_addr."', '". $pagename."', '".$hitcount."', '".$pagevar."', '".$searchterm."')"; $insert_result = mysql_query($insert_query) or die(mysql_error()); It worked before I changed the database structure. I reduced the number of columns and now it seems that the included file executes twice and, for the second execution, does not take the variables set in the main file into account. So, I get two rows added to my table...one with all variables, even the ones set in the main file; and a second row with just the IP address and date.
Strip Tags With Contents N Times
What is the best way to delete tags n times from either the beginning or the end of a String? For example, to delete "someString1" and "someString2" along with surrounding <someTag>'s with n=2 and processing direction is from beginning. $someBigString="<someTag>someString1</someTag><someTag>someString2</someTag><someTag>someString3</someTag>"; I was thinking about use preg_replace() to replace "/</tag><tag/" with "" but wasn't sure how, especially about the n times and direction of processing.
Slow Response Times (php + MySQL)
so my site is finally done but the main page takes about 4-5 seconds to load. It's about 50KB and I have a 1.5 MB DSL so it's not the loading time. Right now it searches through about 1500 records and returns about 50 of them with name, URL, image and a few other options. The site is not public yet and I notice that mysql take 60-90+% of the CPU but barely 3% of the memory when I call that page. Tried it plenty of times to make sure that's why it spiked. What's scaring is that the records will increase to at least 10,000. I have eAccelerator and I have no problems with a php-nuke site with way more records. It loads really fast, but I have removed a lot of the bells and whistles; here I need them. The server: Fedora II, a 2.4 P4, 1 GB Ram, MySQL 3.58, server load almost never goes above 0.50, even during the "delays" and when mysql taking 98%. After an OS /Apache 2.0 upgrade, I've noticed that I only have one mysql proccess running, before I had dozens. Is this better or worse? [root@********etc]# more my.cnf [mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock [mysql.server] user=mysql basedir=/var/lib [safe_mysqld] err-log=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid I have no problems with individual pages at all in this site. What do you guys suggest? Is my .cnf the problem? Unfortunately the program is finished, too late for database changes, if that's the problem. Can I "cache" the index page with an additional program and update it manually or every hour or so? Eventually I will upgrade to MySQL 4.* but right now I am swamped with updating and testing the new site and can't risk downtime. Any help would be greatly appreciated. some more mysql data, in case it makes sense to someone ;): ------------------------ system locking is not in use Possible variables for option --set-variable (-O) are: back_log current value: 50 bdb_cache_size current value: 8388600 bdb_log_buffer_size current value: 0 bdb_max_lock current value: 10000 bdb_lock_max current value: 10000 binlog_cache_size current value: 32768 connect_timeout current value: 5 delayed_insert_timeout current value: 300 delayed_insert_limit current value: 100 delayed_queue_size current value: 1000 flush_time current value: 0 innodb_mirrored_log_groups current value: 1 innodb_log_files_in_group current value: 2 innodb_log_file_size current value: 5242880 innodb_log_buffer_size current value: 1048576 innodb_buffer_pool_size current value: 8388608 innodb_additional_mem_pool_size current value: 1048576 innodb_file_io_threads current value: 4 innodb_lock_wait_timeout current value: 50 innodb_thread_concurrency current value: 8 innodb_force_recovery current value: 0 interactive_timeout current value: 28800 join_buffer_size current value: 131072 key_buffer_size current value: 8388600 long_query_time current value: 10 lower_case_table_names current value: 0 max_allowed_packet current value: 1048576 max_binlog_cache_size current value: 4294967295 max_binlog_size current value: 1073741824 max_connections current value: 100 max_connect_errors current value: 10 max_delayed_threads current value: 20 max_heap_table_size current value: 16777216 max_join_size current value: 4294967295 max_sort_length current value: 1024 max_tmp_tables current value: 32 max_user_connections current value: 0 max_write_lock_count current value: 4294967295 myisam_max_extra_sort_file_size current value: 256 myisam_max_sort_file_size current value: 2047 myisam_sort_buffer_size current value: 8388608 net_buffer_length current value: 16384 net_retry_count current value: 10 net_read_timeout current value: 30 net_write_timeout current value: 60 open_files_limit current value: 0 query_buffer_size current value: 0 record_buffer current value: 131072 record_rnd_buffer current value: 0 slave_net_timeout current value: 3600 slow_launch_time current value: 2 sort_buffer current value: 2097144 table_cache current value: 64 thread_concurrency current value: 10 thread_cache_size current value: 0 tmp_table_size current value: 33554432 thread_stack current value: 65536 wait_timeout current value: 28800
Finding Time Difference Between Two Times.
I want to have a script that reports the last activity that a user had, and stores that in a database. So I'll pass there PHP Sess ID into the URL's, and then update the database with each link they click on. When they come back later and login again, I need to find out the time difference between the two logins, as I want to give people credits every hour, and don't want to have to run a cron to do this, so instead I just work out the time difference when they relogin and allocate them credits accordingly (its a game). I am no good at working with dates though. There is so many formats - so I wouldn't have a clue which would be the best to use, especially when you want to do calculations with it. I donno if a MySQL time stamp would be good, as when they relogin the value will be generated with PHP, not from MySQL.
Loading Times For Php Generated Pages
I've just noticed on my own surfing of the net and some php pages that i've done. especially long pages.... that they seem to load in blocks... one section at a time is there some sort of buffering or something that is doing this and can be turned off? I"m not that experienced in php... but know enough.
Comparing Two Times Using Unix Timestamps
I want to use the unix timestamp to select a time like this code displayed below. Currently its using the strftime function of php but its not accurate because its comparing two string values and I want it in timestamp interger format. PHP Code:
Counting How Many Times A Word Appears In A Var?
I've made a small search function as of here: if (stristr($bleh,$search_for)){ if(preg_match('/<title>([^<]*)</title>/i', $bleh, $matches)) { $name = str_replace("./","/",$name); echo "<li><a href=$link".$name.">".$matches[1]."</a><br><br>"; } Now this actually works fine, and gives me a page link and title of a page, based on pages that contain the search term. Im now trying to rationalise the code a bit more, so that the order of the links depends on how many times that certain word appears on the page.
Capturing File Modification Times
I was just wondering if it was possible to capture a file's modification time before it is uploaded through a from post. For instance, I know you can get the name & type of file's orignal values as the file is being uploaded but is it possible to get the mod date?
Check How Many Times A Word Is Written
I am trying to check how many times a word is written in a variable. Lets say I have a story, and want to know how many times "walked" is written. I guess I will need a loop of some kind, but I'm not sure.
Insert Character Specified Number Of Times
im looking for a function that will create a string of a certain character a specified number of times. ex. $newstring = unknownfunction("*",5) //resulting in $newstring being ***** I know how to create a loop to do this, just wondering if such a function exists.
Mktime() Giving Me Different Times When Run From Different Servers
mktime() is giving me different times when run from different servers. Of course this would be normal if I were running the function empty, but here's what I'm doing: $y = date('Y', (mktime() - 10800)); // 3 hour diff w/ server $m = date('m', (mktime() - 10800)); $d = date('d', (mktime() - 10800)); $this->today = mktime(0,0,0,$m,$d,$y); (the 3-hour adjust is only because the client's timezone is 3 hours off from the server's - it's done so that the entries they make flip over to the next day at midnight in their time zone, not the server's) Anyway, $this->today should always be midnight on the day specified, since I'm feeding it zero minutes, seconds, hours and a specific day, month, year. Instead it's 4 hours later in the server's timezone (1122696000) and 7 hours later in the client's timezone (1122706800). So not only is it wrong, it appears to be deriving its hour setting from the server, rather than using the 0 I'm feeding it. What the heck am I doing wrong? How can I get the zero hour/minute/second of the specified day as a unix timestamp?
OS Detect
would it be possible to detect the client's OS system with php? i don't need much detail, only if its a Windows, a linux or a macintosh system.
|