-
Posts
1,832 -
Joined
-
Last visited
-
Days Won
3
Everything posted by salathe
-
Get in contact with Google and request a partnership. That would be the only offical way of getting all of the results for a search. Other options include using their APIs (which provide limited results) or literally scraping the results from the Google web interface (which probably is not allowed programatically).
-
Kudos to Facebook for open sourcing the tool and it obviously suits their needs very well. As for whether this will become widely used outside Facebook, that's really not the point. Chances are, most of PHPFreaks' membership won't be needing a PHP to C++ compiler anytime soon (for anything other than educational value).
-
The answer depends on your proficiencies and the tools available to you. For example, regex might be easier for you to pick up and write a quick script doing what you want (get those tags' contents). For me, it might be easier to use a document parser and access the structure (e.g using Tidy, DOM and friends) to get at the tags' contents. For someone else, get_meta_tags() might work fine (assuming they were not wanting the title!). If you're not comfortable with one method over another (or not aware of others to compare against) then that's also going to come into play with regards to the "easiest" way to do something.
-
mysql_real_escape string or htmlspecialchars, etc. what to use?
salathe replied to justAnoob's topic in PHP Coding Help
It's better than nothing. Another, preferable, technique in the code that you just posted would be to explicitly look for digit-only input since it is really an ID number being used in the query. Also, none of this has any bearing on whether the input will be safe for display, which is an entirely separate concern. -
If Date is 0000-00-00 I want PHP to return NOTHING
salathe replied to liam1964's topic in PHP Coding Help
Is there any particular reason why the default is 0000-00-00? If you allow the column to have NULL values in the table, you won't have to use PHP to look for the special zero date. -
In your code you have $database_login = Registry::get("database_login"); $databse_password = Registry::get("database_password"); Note that later you use the variables $database_user and $database_password
-
function Testing($value) { echo $this->Settings->{'page_' . $value}; exit; } Testing('hello');
-
Open txt file - Remove all blank lines and save txt file.
salathe replied to new2code's topic in PHP Coding Help
A quick (in terms of lines of code at least) would be: file_put_contents('logs.txt', implode(PHP_EOL, file('logs.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES))); If the file is particularly large (i.e. if loading it into memory isn't trivial) then it would be better to go through the file in pieces (like, line-by-line), writing non-empty lines to a temporary file then moving said temporary file to the original location once the process is complete. -
Heard of BrowserShots? (Automated browser screenshots) Hehe!
salathe replied to oni-kun's topic in Miscellaneous
Is the purpose of this thread to discuss remote-rending-services or to show that you've found a way of crashing a really crappy browser? -
It's note quite the same algorithm but you could use str_rot13 (to get Uryyb Jbeyq).
-
It probably makes more sense to use m/d/y
-
Why Won't This Short Code Work? Writing to RSS File...
salathe replied to yortzec's topic in PHP Coding Help
You only open the file for reading, not reading and writing (see the 2nd line of your code posted above). That's quite apart from your code being malformed (see where the syntax highlighting breaks in your post). -
Given your posted XML, shouldn't $xml->items->item instead be $xml->item ?
-
zohab, please ask a question or at least suggest a topic of discussion. Otherwise, we've no idea what you want to know.
-
What's the best naming convention for functions
salathe replied to drtanz's topic in PHP Coding Help
Any, so long as it is clear (like camelCase and under_scored), descriptive and consistent throughout your code. -
Execute multiple process without pcntl_fork()
salathe replied to jim_de_bo's topic in PHP Coding Help
Ah now the story unfolds. How happy would you be starting from scratch with a completely new approach? Unless there is any real reason for doing so, it would be much preferable to work only one remote file if possible (ideally, 300 different scripts all running at once): some form of task/queue framework would be good. If that sounds like too much hard work, you could also use cURL to fetch the files in batches (or say 50, 100, or even 300) in parallel and you can then be working some files while the rest are still being fetched: for this, look to using the curl_multi_* functions. -
regular expressions to validate username (allow only letters and _ )
salathe replied to Vivid Lust's topic in PHP Coding Help
Move the underscore (_) one character to the left and put a plus symbol (+) where it was. Then tell my why that would work. -
Execute multiple process without pcntl_fork()
salathe replied to jim_de_bo's topic in PHP Coding Help
What are the major factors in the performance of your script, what is making it particularly slow: large files, lots of files, remote files (all of the above)? -
Yes it's possible, in a variety of ways. You could use/learn JavaScript (maybe made easier with jQuery or some other helper framework) only, or you could use JS and PHP or some other scripting language to "interpret" the XML and sort into different divisions as you like.
-
What does your string look like (e.g. is it an HTML page, random text file, etc.)?
-
Problem using strtotime to convert two variables into a date
salathe replied to ghurty's topic in PHP Coding Help
In the first line, the $month and $day variables are in the wrong places (switch them around) since obviously there is no month 25! (Sorry) This was a very simple mis-type and something you really should have been able to figure out yourself, considering you knew the input given was in ddmmyy format. As for it "no matter what" outputting Wednesday, I've no idea how you got it to do that. -
Where did you get the idea to use $query->recordcount() from? It looks like $query should either by a resource or boolean (true/false), not an object. Try $db->numRows($query) instead.
-
On (or near) line 30, you'll have code that looks like ->recordcount( which is causing an issue. Diagnosing the precise cause (other than the variable to which it is attached not being an object) needs us to see a sample of the code. If the script isn't too long (nor contains sensitive information) please post it here, or at least a portion of the script surrounding line 30. Edit: typos
-
Unless I'm missing some finer point, your code could alternately be: $data = explode(',', $r); foreach ($data as $key => $value) { $data[$key] = explode('~', $value); } print_r($data);
-
Problem using strtotime to convert two variables into a date
salathe replied to ghurty's topic in PHP Coding Help
The two lines below extract the day, month and year from your example date using sscanf and gets the day of the week using those values and strtotime/date. It's just one example of getting what you wanted. sscanf('012510', '%02d%02d%02d', $day, $month, $year); $dayoftheweek = date('l', strtotime("20$year-$month-$day")); var_dump($month, $day, $dayoftheweek);