1. Delaying a script

    Date: 03/21/06     Keywords: no keywords

    I'm having a bit of a problem getting a script to delay for a few seconds before it redirects the user to a new page.

    What I want is

    - so someting
    - display someting
    - sleep(5); //The delay
    - redirect($url);

    what i'm getting is

    - 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

    Pual

    Source: http://community.livejournal.com/php/429226.html

  2. finding and replacing a string in a database entry

    Date: 03/20/06     Keywords: php, database

    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 ^^

    Source: http://community.livejournal.com/php/428632.html

  3. PHP IDE w/ Streamlined Synchronizaiton

    Date: 03/18/06     Keywords: php, web, apache

    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).

    Source: http://community.livejournal.com/php/428141.html

  4. Auto Populating a table?

    Date: 03/17/06     Keywords: mysql, browser, sql

    I've writen a function


    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.

    each line is in the format

    insert into 'area' values(0, 'Yorkshire')

    am I missing something?

    Tia

    Pual

    Source: http://community.livejournal.com/php/427879.html

  5. PHP Help

    Date: 03/17/06     Keywords: php, html

    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:

    curl http://.../all-stories-num.php -o /home/.../all-stories-num.html

    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:

    curl http://.../charbytitle.php?cid=80&letter=W&pageno=1 -o /home/.../ofcw.html

    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?

    cross-posted to '[info]'php_dev and my journal

    Source: http://community.livejournal.com/php/427596.html

  6. :: vs ->

    Date: 03/15/06     Keywords: php, google

    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

    thanks

    Source: http://community.livejournal.com/php/426221.html

  7. Automatically pass variables

    Date: 03/15/06     Keywords: php

    Is there a way to have variables automatically passed via links on a page? 

    For instance, say I have this link: (a href=page.php)page(/a)

    Instead of manually coding page.php?foo=bar, can PHP auto append variables to page.php when users click the link?

    Sorry if this isn't making much sense.  I don't know how else to explain it.

    Source: http://community.livejournal.com/php/425668.html

  8. cURL

    Date: 03/15/06     Keywords: php

    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.

    Source: http://community.livejournal.com/php/425000.html

  9. Processing RTF Files with PHP

    Date: 03/13/06     Keywords: php, html

    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 :(

    Source: http://community.livejournal.com/php/424835.html

  10. Might be a daft question..

    Date: 03/13/06     Keywords: php

    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?

    Many thanks..

    Source: http://community.livejournal.com/php/424650.html

  11. arrays

    Date: 03/12/06     Keywords: mysql, database, sql

    Hi,

    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 :

    theatre
    year1 title1
    year2 title2
    etc


    movies
    year1 title1
    year2 title2
    etc


    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 "
    "; echo "\n$genre"; echo "\n"; $liste = mysql_query("SELECT * FROM $nom WHERE categorie LIKE '" . $genre . "' ORDER BY annee DESC",$connexion); while ($row = mysql_fetch_assoc($liste)) { $annee = $row['annee']; $titre = $row['titre']; $complement = $row['complement']; echo "\n "; } echo "\n
    $annee$titre$complement
    "; echo "
    "; }


    Any help would be greatly appreciated !

    Source: http://community.livejournal.com/php/424221.html

  12. checking a variable against multiple values

    Date: 03/09/06     Keywords: no keywords

    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


    if ($x == 1 || $x == 2 || $x == 3) {
    do_some_junk();
    }


    which seems kind of messy. it'd be nice if there was something like


    if ($x in(1,2,3)) {
    do_some_junk();
    }


    i've tried experimenting but haven't come up with anything.

    Source: http://community.livejournal.com/php/423794.html

  13. .htaccess help

    Date: 03/09/06     Keywords: web

    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.

    RewriteEngine On
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http://(www\.)?projectsquish\.net/ [NC]
    RewriteCond %{HTTP_REFERER} !^http://(www\.)?icons\.projectsquish\.net/ [NC]
    RewriteCond %{HTTP_REFERER} !^http://(www\.)?livejournal.com(/)?.*$ [NC]
    RewriteCond %{HTTP_REFERER} !^http://([a-zA-Z0-9_]+\.)?livejournal.com(/).*$ [NC]
    RewriteRule \.(jpe?g|gif|png)$ images/no_hotlink.gif [L]

    Source: http://community.livejournal.com/php/423463.html

  14. Output Validation?

    Date: 03/09/06     Keywords: php, mysql, sql

    Hi guys,

    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?

    Posted to '[info]'php, '[info]'sqlserver, and '[info]'mysql

    Source: http://community.livejournal.com/php/423247.html

  15. Locale and strftime

    Date: 03/08/06     Keywords: php, rss

    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?

    Cheers.

    Source: http://community.livejournal.com/php/422960.html

  16. Reg ex help

    Date: 03/08/06     Keywords: no keywords

    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.

    Source: http://community.livejournal.com/php/422685.html

  17. PHP and RSS/RDS?

    Date: 03/07/06     Keywords: php, html, web

    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:

    http://redsox.feedster.com/

    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!

    Cheers, Derek



    (X-Posted in WebDev)

    Source: http://community.livejournal.com/php/422408.html

  18. any suggestions?

    Date: 03/06/06     Keywords: php, mysql, sql

    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!

    Source: http://community.livejournal.com/php/422191.html

  19. Tour Guide to PHP

    Date: 03/05/06     Keywords: php, programming

    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:

    http://www.uic.edu/~kayiwa/started.pdf
    http://www.uic.edu/~kayiwa/specifications.pdf

    I need a kick in the rear on where to begin... and any suggestions... (the manual is already open :-)) will be greatly appreciated.

    TIA

    Source: http://community.livejournal.com/php/422021.html

  20. Why?

    Date: 03/05/06     Keywords: no keywords

    In this example:

    it works.


    In this:

    it doesn't.

    Source: http://community.livejournal.com/php/421839.html

Previous page  ||  Next page


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home