Jump to content

Mcod

Members
  • Posts

    38
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

Mcod's Achievements

Member

Member (2/5)

0

Reputation

  1. Hi there, another short question regarding a query: I want to show some data in categories called A - Z and in another category which contains non A-Z items. For the a - z queries this is easy: $thequery = mysql_query("SELECT * FROM allitems where thename like 'a%' ORDER by thename ASC LIMIT $offset, $limit"); However, I would also like to have a category with items that do not start with a - z, for example items like !Great or items that start with a number like 1Great or even things like *Great Sure, I could do it in a dirty way like: where thename NOT like 'a%' AND thename NOT like 'b%' AND thename NOT like 'c%' but I am sure there is a better solution with some REGEX query or something similar which I don't know about. Maybe you have an idea how this would work out best? Thank you
  2. @Barand, thank you for your solution - it worked really great @Christian F. The reason is saving queries - Categories will not change and this way I can get all details with one simple query without the need to do additional queries on another table. This sometimes matters if you run a large site and you have to watch how many queries you do. I understand what you are saying, but in my case this is the better solution. Thanks again
  3. Hello, I am looking for a solution to this: 1.) I have a table called font where each font has a unique id called id 2.) I have a table called font_categories_join where each font id (above) has a categoryid What I am trying to do is getting the categoryid into my font table, basically something like updating fontcat (from font table) and setting the fontcat to the value that is in my categoryId inside the font_categories_join table Detailed example: table font contains this: id fontName fontcat 1 some name 0 table font_categories_join contains: fontId categoryId 1 12 so what I am trying to do via phpmyadmin is updating the fontcat in the font table from 0 to the correct category 12 Your help would be appreciated
  4. For me it's simple, I have a value like 22 and to me it's clear that "22" means "Cars" and "2" means "Business". So what I get from my mysql database is the value 22 which means the listing is for the category "Cars" and a result with 2 would be the category "Business". Since I have to print out the category in human-readable form instead of showing "Category: 22" I am looking for a function to convert the number 22 into the word "Cars" - right now (as you know) it would echo BusinessBusiness which is not what I want
  5. Thank you for your reply. The reason why I need to do this is because I had a script coded and there are category numbers which I want to replace with words. There are 40 categories, so I looked up some ways to solve this, but as you can see, it causes more pain than it does good Any recommendation how to solve this with a similar function that actually works? Thanks
  6. I am having issues with replacing strings - see example below: function getname($string) { $search = array('0','1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22'); $replace = array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v"); return str_replace($search, $replace, $string); } If I run getname(22); then it returns cc instead of v, meaning it replaces the 22 with two times the 2 Your help would be appreciated Thanks
  7. Hi salathe, giventhe fact that I really have no clue about how to even get started with this, I would love to see a complete solution with maybe some comments on "why this will work best" so I can learn from it when I need to complete similar tasks. So yes, I am more looking for a "complete solution" instead of pointers, as I am currently doing this all by hand (about 100000 lines per day) so it would save me a lot of time.
  8. I am looking for some help with extracting links from log files, as it is a pain to do this manually (which I do right now). I basically have some log files which I need to check for ERROR messages and copy and paste the found URL's into another text file. My log file format looks like this: INFO <11 Feb 2012 00:00:23,822> <index> <D2> <Processing URL : http://www.domain1.com/> INFO <11 Feb 2012 00:00:23,842> <index> <D4> <Indexed: http://www.domain2.com/> <Time:146 msecs> INFO <11 Feb 2012 00:00:23,842> <index> <D4> <Processing URL : http://www.domain3.com/> ERROR <11 Feb 2012 00:00:23,924> <index> <D1> <http://www.domain4.org/operas/2003-2004/mourning/composer.aspx: > org.apache.commons.httpclient.HttpRecoverableException: org.apache.commons.httpclient.HttpRecoverableException: Error in parsing at org.apache.commons.httpclient.HttpMethodBase.readResponse(HttpMethodBase.java:1965) at org.apache.commons.httpclient.HttpMethodBase.processRequest(HttpMethodBase.java:2659) at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1093) at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:674) at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:529) at com.searchblox.scanner.http.HTTPScanner.b(Unknown Source) at com.searchblox.scanner.http.HTTPScanner.scan(Unknown Source) at com.searchblox.scanner.http.HTTPScanner.work(Unknown Source) at com.searchblox.scanner.Scanner.run(Unknown Source) at java.lang.Thread.run(Unknown Source) INFO <11 Feb 2012 00:00:23,968> <index> <D5> <Indexed: http://domain6.com/~cdobie/kearnsindex.htm> INFO <11 Feb 2012 00:00:23,968> <index> <D5> <Indexed: http://domain7.com/~cdobie/kearnsindex.htm> INFO <11 Feb 2012 00:00:32,988> <index> <D1> <Processing URL : http://www.domain8.com/> INFO <11 Feb 2012 00:00:33,072> <index> <D5> <Indexed: http://www.domain9.com/> <Time:128 msecs> INFO <11 Feb 2012 00:00:33,072> <index> <D5> <Processing URL : http://www.domain10.com/> ERROR <11 Feb 2012 00:00:33,116> <index> <D2> <http://www.domain11.com/: Connection timeout> org.apache.commons.httpclient.HttpConnection$ConnectionTimeoutException at org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:736) at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:661) at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:529) at com.searchblox.scanner.http.HTTPScanner.b(Unknown Source) at com.searchblox.scanner.http.HTTPScanner.scan(Unknown Source) at com.searchblox.scanner.http.HTTPScanner.work(Unknown Source) at com.searchblox.scanner.Scanner.run(Unknown Source) at java.lang.Thread.run(Unknown Source) INFO <11 Feb 2012 00:00:33,154> <index> <D1> <Indexing http://www.domain12.com/ ...> INFO <11 Feb 2012 00:00:33,159> <index> <D1> <http://www.domain13.com/ - Last-Modified date: Sat Feb 11 00:00:33 CET 2012> ERROR <11 Feb 2012 00:00:33,207> <index> <D6> <http://www.domain14.com/: Connection timeout> Now what I am after is some piece of code which basically saves the http://domain.com/ part to a text file IF the line starts with ERROR. There are many different error reasons, so the strings are all different at the start and at the end, so maybe you know a way to open a log file, look out for the word ERROR at the beginning of a line and if that's the case, either save the whole line to another text file or if possible just the domain part (which would be even more great) If possible, please post a fully functional code block, as I am extremely bad with anything that has to do with regex, opening and closing files etc. Your help would be greatly appreciated I attached a sample log file to this post in case it helps (same as the lines above) 17560_.txt
  9. Hi there, My big question of the day is: Do you know of any tool / script to detect a web site's language? I basically have a list of 1 million URL's (Alexa Top 1 Million by rank) and would like to batch check the URL's to find out which site is written in English and filter out the ones who are not. I have the data in a mysql database, but checking so many URL's one by one by downloading the site, analyzing the text and guess what language it is takes too many server resources (I tried). That said, do you maybe know a tool or API which can "guess" the language by feeding a list of URL's? Thanks
  10. And here is the feedback: It worked perfectly. I manipulated all four files and it took less than a second per file. Thank you so much! This did help me a lot, as I was close hiring someone to do it by hand. Thanks again - this is really a great forum
  11. I'll give .josh's solution a try and see how it goes. I have sadly all data in one large file, and my mission is importing it to a mysql database after it has been cleaned. So it makes more sense to clean it with PHP and insert it instead of inserting it to the db and trying to clean it then Will report back once I'm done testing! Thanks for all your help so far
  12. I am looking for some help with manipulating a text file. My lines have the following format: abc|some words here; some other words here bcd|some words here; some other words here and even more words sometimes I have about 150000 lines in my file. Sometimes there is a second meaning, separated by a ; and sometimes not. Sometimes there are even more than two meanings. What I am after is removing everything INCLUDING the ; line by line - ALWAYS the FIRST ; even if there are multiple (which can happen, as you can see below). What I basically have here is a dictionary where the word is on the left, then we have the | character and then one or more "meanings". Sample data: cough|exhale abruptly, as when one has a chest cold or congestion; "The smoker coughs all day" hack|cough spasmodically; "The patient with emphysema is hacking all day" expectorate|discharge (phlegm or sputum) from the lungs and out of the mouth snort|make a snorting sound by exhaling hard; "The critic snorted contemptuously" wheeze|breathe with difficulty What I am after is basically: cough|exhale abruptly, as when one has a chest cold or congestion hack|cough spasmodically expectorate|discharge (phlegm or sputum) from the lungs and out of the mouth snort|make a snorting sound by exhaling hard wheeze|breathe with difficulty It would be great if you have any sample code that could help me, as it would be no fun to remove all this by myself if there is a solution to just do it with PHP and there is always one Thanks for your time!
  13. Thanks for all your replies I managed to get it done, added some validation things and everything is set now Thanks again!
  14. Hi there, I am looking for a solution to split a string like this: $string = "jim.h|1234567890123456|0"; so I get three values 1.) jim.h 2.) 1234567890123456 3.) 0 I also need to validate that all parts exist. Part 1 before the | can be any length and only contain a-z 0-9 the minus sign and a dot - no spaces or any other characters. Part 2 (between the first and second | separator) must be a 16 chars string which must be 0-9 and a-z Part 3 must be a number, either 1, 2 or 3 If all conditions are given, I would like to isert this into a mysql database like INSERT INTO employees (name,key,level) VALUES ('$part1','$part2','$part3') - I know how to do this - even if I suck at other things It's important that a record only gets insert if all of the above is correct. This bit of code is all about user errors and people trying to manipulate the submitted AJAX form, so I want to make sure only valid characters can be submitted and that all values are required. Thank you for your time reading this
  15. I managed to fix this - might be a bit "dirty" but it works for me: $articledate = "2012-01-25"; $utc = $articledate; $utc = strtotime($utc); header('Last-Modified: '.gmdate('D, d M Y H:i:s \G\M\T', $utc));
×
×
  • 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.