- do something - sleep(5); // The delay - display something // which goes by too fast to read - redirect($url);
is there someting about the sleep() function that makes it the first function in a script to be exercuted before anything else in its ennclosing function is?
Any help would be welcome - I'm running out of hair here
I'd like to find and change the word "images/" in a database entry, and replace it with "http://mydomain.net/images/". Is there some way to do that with PHP, without having to update anything in the database? I've tried it with preg_match(), but that didn't do anything. I'm still PHP noob anyways ^^
I've been looking for a good IDE that supports PHP and have been unable to find anything really useful. I'd prefer it if I could have a streamlined updating feature, because manual updating via FTP/[insert uploading method here] is a real drag. The best I've found so far has been a plug-in for Eclipse. However, it's really laggy (every time I go to type a variable name, I get a pop-up of EVERY INSTANCE of EVERY PHP VARIABLE NAME in the entire Eclipse project), and Eclipse's WebDAV support seems very broken, with no intentions on fixing it (a stupid decision, IMHO, considering WebDAV support is touted as a major Eclipse feature).
Anybody have any recommendations? I'm really accustomed to the way IDEs such as Visual Studio, NetBeans and Eclipse work. I'm on a tight budget ($0) and I'd prefer if the solution was Free. An added plus would be WebDAV, SFTP or SCP support. My Debian server's running Apache2 with the WebDAV plugin turned on and working pretty efficiently. I have proftpd installed and marginally working, although I'd rather not use that due to no encryption. To the best of my knowledge, I don't have an SFTP or SCP daemon running on that machine (unless there's one magically bundled with proftpd).
auto_populate($file_name) {     $file=file($file_name);     foreach($file as $sql)     {        mysql_query($sql);        echo $sql."< br >"; // To test the file is being processed     } }
if I call it with a filename (eg. auto_populate("test.txt");) I see the lines in the browser but the db still remains empty.
Okay, a little back story. For several years now I've had some php queries of story listings. I don't want them run repeatedly, so in addition to this I run a cron job with curl statements like:
This has worked beautifully, makes an HTML for each file, and I just run it nightly to account for updates during the day. However, as the site has grown, there number of PHP files has grown to 1010. So I thought I'd consolidate them into a few files passing variables in to differentiate. Then still run a cron of curl statements, except now they'd look like this:
Well after extensive testing, apparently this won't work, at least not the way I've done it. The curl statement doesn't handle the variables passed in.
Does anyone have any ideas of how else I could get the same effect? i.e. one HTML for each type of query without having to maintain over a thousand PHP files? Or someway to cache the results for 24 hours if I used the PHP files directly?
I should probably know this but it's hard to google for
what's the difference when using classes in php between saying object::method() and object->method()
also, while i'm on the subject, what's the significance of beginning a method with "__" as in $object->__get() - i guess this is a naming convention, but i can never get why you would use __get() over just get(); i'm just not sure what that implies
The cURL extension doesn't want to install for me - I have php 4.3.9 and the default php_curl.dll didn't want to run when I uncommented it in php.ini. It gave me:
"(null): Unable to initialize module Module compiled with module API=20040412, debug=0, thread-safety=1 PHP compiled with module API=20020429, debug=0, thread-safety=1 These options need to match"
When I download version 0.9.8.1 of php_curl, I get:
"Unable to load dynamic library './ext\php_curl.dll' - The specified procedure could not be found.".
I'm not really sure where to go from here. I've tried all sorts of combinations of libeay32.dll and ssleay32.dll in the system32 and PHP directories, both with the version that came with PHP 4.3.9 and the 0.9.8.1 one.
Nevermind. I re-downloaded PHP 4.3.9 and apparently I had a different php_curl.dll.
Has anyone come across some PHP code to process RTF files?
I'm trying to get a script together to convert an RTF file into HTML for an Intranet site, but seem to be having no luck, and my Googling is not turning up anything :(
is there any way to get PHP to retrieve the currently logged on user in windows XP, on a domain? I'm doing a bullying feedback form in a school, and it's being abused with false names/details etc...
If I do a "Set" command in XPs command prompt, it does return the USERNAME= variable with the current user..but can I get PHP to read this and chuck it in the text file with the rest of the feedback?
I'm sure there's a better way than the one I'm using to do what I want to do. I'm trying to select items from a database and order them by "category", which is one of the columns of the table I use. Then, I want the page to display the items with the category as a title, appearing only once. Hopefully someone can help me improve my code :)
Here's what the table looks like : ____________________________ | category | year | title | stuff | ------------------------------------------ | theatre | year1 | title1| ... | ----------------------------------------- | movie | year2 | title2 | ... |
Here's what I want :
Here's the code I use :
$categorie = mysql_query("SELECT categorie FROM $nom",$connexion) or die(mysql_error());
$nb = mysql_num_rows($categorie);
for ($i = 0; $i<$nb; $i++) {
$perf = mysql_result($categorie,$i);
$item[] = $perf;
}
$reduc = array_unique($item);
foreach($reduc as $genre) {
echo "
aside from dumping the values into an array and then using in_array(), is it possible to write a comparison statement that checks against multiple values? i often find myself doing something like
I've recently put a .htaccess file on my website to help prevent hotlinking of my icons, however I don't quite understand a lot of the coding for it. I'm not 100% sure if what I've put is even correct, because some people (including myself) have been able to see my icons, and others are seeing the no hotlinking image, and I don't understand why (though I've been told that it could be something to do with a firewall setting).
If anyone could tell me if I have my .htaccess written out correctly, or give me some tips on it, I'd really appreciate it.
I'm wondering if it's possible to validate the output of an sql query?
I have the following query/code (using PHP5, and MSSQL):
$sql = "SELECT TOP 100 PERCENT Mem_Number, Title_1, Name_1, Surname_1, Email, Date_Sent_Renewal, EmailList, Renewal_Date FROM BTCMembers WHERE (DATEDIFF(d, Renewal_Date, GETDATE()) > ".$cutoff.") AND (DATEDIFF(d, Renewal_Date, Date_Sent_Renewal) < 0) AND (Email <> '') AND (Date_Sent_Renewal <> '') AND (EmailList = 1) ORDER BY Mem_Number ASC";
$result = odbc_exec($contact, $sql); // Run the query
Now this query works exactly as I expect it to, but some of the data which is pulled could cause minor problems later.
Specifically, there are a few records which have an "Email" field value of "N/A" -- the fault of dodgy input validation, I know, but I didn't make the input interface. *shrug*
So, is there a way to write the query so that data pulled from the Email column must make a regular expression valid for email addresses?
I need to produce date times in an ISO standard format for RSS feeds.
This requires the format to include month and day abbreviations (jan, feb, mar... mon, tue, wed) etc.
These must be in en_gb (same as en_us) format for the date format to be correct.
strftime insists on formatting to the locale settings, so I get things like
Mi, 08 Mär 2006 14:42:05 +0100
Which is no use It has to be Mon, 08 Mar 2006 14:42:05 +0100
Is there anyway to do a getlocale so I can cache the old locale before calling a setlocale to override to en_gb briefly for the stftime operation then quickly set PHP back to the old locale for the rest of the processing?
Or do I really have to re-implement strftime in a locale-insensitive way?
I'm trying to figure out the most efficient way to ensure that a space follows a comma in a string. For example I have an input string:
"C1,C2,C3"
with no spaces after the commas. I'd like to convert that to
"C1, C2, C3".
I can think of several ways of doing this iterating over each character in a string checking for commas not followed by spaces, or exploding the string, trimming whitespace, adding a space and concatenating it all back together again. But it seems like a preg_replace() or a ereg_replace() might be a more efficient solution. I don't want to add a space if it already exists.
I have tried this:
ereg_replace(',[^ ]',', ','C1,C2,C3');
but it gives me:
"C1, 2, 3"
Any suggestions? I'm not a regular expressions expert at all.
Hello, I guess I'll preface my question by stating that I'm as newbie as is gets with PHP. I'm going to type what I'm looking to do below and hopefully I'll be able to funnel my search towards an answer. Thanks so much ahead of time for any help any of you can give me.
I currently write and keep a blog on and about the Boston Red Sox (SawxBlog.com) and through doing this blog I had an idea. I'd like to create and improve on a site that's similar to the below site:
Basically what I'd like to do is subscribe to every and all Red Sox blogs and feeds (with permission of course) and have them come up linkable, with a only few sentences showing from the post, much like the feedster example above and baseballblogs one below. I'm looking to add a lot more blogs, as well as make the overall appearance more "eye pleasing" along with some original content. Another site that sort of does this is http://baseballblogs.org/.
From doing a lot of random internet research it seems like the best way for me to accomplish this is via PHP. I found this site that was helpful (to a point) in introducing me to the possibilities of this. 'Option 3' seemed to make the most sense to me, however it still left a lot of questions of mine unanswered.
What I'm wondering is this: - Is PHP the best way for me to make this site? - Are there any specific tutorials/sites that would be a good resource for me?
I have a background in web design and multimedia with basic HTML as my only real coding background (aside from Action Scripting).
Thanks so much again for any help you're able to give, and sorry this was so long!
A friend of mine is writing a comic book and he wants to post it online and make it a subscription based thing where every month or so he adds new content.
I'm going to be using php/mysql to make this happen, but beyond that the details are knda fuzzy. I've got most of it mapped out, the place I am having problems is when subscriptions come into play (this is only because I have never taken on this kind of project before).
Any suggestions as to the tools I would need to create a subsciption based site? I'm also trying to keep this as inexpensive as possibe >< Chances are he'll be using paypal.
Anything to point me in the proper direction would be much appreciated! Thanks!
I was wondering if any of the seasoned PHP people can help me get my "baptism under fire" I have been programming "mostly python and C and the occasional dabble with Perl". I hope this project that requires me to use PHP will diversify my skill set but time is not my friend.
I have a simple perl script that I have used before to payments to an E-Commerce payment center. Ordinarily I would use it but circumstances I cannot get into do no allow for that. The API to write to this is below: