1. Recompiling apache and PHP

    Date: 09/23/05 (Apache)    Keywords: php, software, apache

    I recompiled apache and PHP months ago to install mcrypt and cURL so billing software would work. I've recently changed billing software, and while troubleshooting the install, found that it wasn't working correctly because mcrypt wasn't installed. So I'm wondering...where'd it go? It *was* installed. Even if apache has upgraded itself recently, it wouldn't make sense that mods would need to be reinstalled each time. I'm just wondering if this has happened to anyone else? I know I'm not providing a lot of details....but I'm not quite sure where to start looking.

    X-posted to '[info]'php and my own journal.

    Source: http://www.livejournal.com/community/apache/25754.html

  2. Birthdays problem

    Date: 09/24/05 (PHP Community)    Keywords: php, mysql, database, sql, web

    I'm doing a web application with PHP and MySQL where members can enter their birthday on their profile. I've done a nice monthly calendar view, and I want to populate the calendar with members' birthdays.

    Can anyone advise me the best way of doing this? Obviously I don't want to do a database request for each day: "Does anybody have a birthday on this day?" - I think we can all guess that 30 database requests would be rather excessive for one page!!

    What I'd like to do is one database request to get all the birthdays for the month and then write it to a 2-dimensional array. Each row in the array will have the user's name, their userid (to link to their profile) and the day of the month which is their birthday. Then all I need do is ask the array if there's any birthdays when I'm writing out the days.

    The trouble is, I'm very unfamiliar with arrays and I'm not sure the best way to do this. Can anyone help?


    Update
    I've found a very useful function which is helping a lot:

    $birthdayquery = "SELECT ID, RealName, DOBDay from Users where DOBMonth = '$month'";
    $birthdays = mysql_query($birthdayquery);
    $arrayindex = 0;
    while ( $birthdayarray[$arrayindex++] = mysql_fetch_assoc($birthdays) );

    You can then do

    $arrayindex = 0;
    foreach ($birthdayarray as $value) {
    	if ($birthdayarray[$arrayindex]["DOBDay"] == $day) {
    		echo $birthdayarray[$arrayindex]["RealName"];
    		echo "'s birthday";
    	}
    	$arrayindex++;
    }


    I think this is going to work!

    Source: http://www.livejournal.com/community/php/346726.html

  3. Host for beta test site.

    Date: 09/24/05 (Web Development)    Keywords: php, mysql, sql, web, apache

    I'm looking for a cheap host which offers the following:


    1. MySQL 4 with InnoDB support

    2. PHP 4 with GD/Image manipulation module

    3. Apache mod_rewrite support



    I'm looking to set up a beta test website for an open source myspace/friendster clone that I'm working on called Appleseed (http://appleseed.sourceforge.net).

    Let me know if you have any suggestions.

    Update: I need SSH access, too.

    Source: http://www.livejournal.com/community/webdev/246550.html

  4. Converting time to seconds

    Date: 09/25/05 (PHP Community)    Keywords: php, sql

    Is there a simple function to convert time (hh:mm:ss) to seconds (or hours)?

    Basically I want to duplicate this SQL in PHP: sum(((TIME_TO_SEC(end_time) - TIME_TO_SEC(start_time))/3600) * rate)


    I've looked here but I dont think I see it.
    http://us2.php.net/manual/en/ref.datetime.php

    Source: http://www.livejournal.com/community/php/347080.html

  5. damn you javascript

    Date: 09/25/05 (Web Development)    Keywords: php, html, java

    Hello

    I'm trying to write some data to a div with javascript,
    It works fine when I write plain text but for some reason i can't seem to get a "table" tag to work in the same manner

    If that doesn't make any sence just look at the example
    Example: http://maps.funvill.com/test.php


    Source:

    Source: http://www.livejournal.com/community/webdev/247004.html

  6. Macromedia products

    Date: 09/26/05 (Computer Geeks)    Keywords: php, ebay

    I can't download the trials of ANY Macromedia product from the company page. Getright keeps saying the files don't exist on the server. Every other site I've found just links back to macromedia.com. Where can I find a mirror of those trials?

    And just for amusement, I found this Goooogle ad on a page about a PHP editor:
    Wysiwyg Editor Sale
    New and used Wysiwyg Editor Check out the deals now!
    www.eBay.com

    Source: http://www.livejournal.com/community/computergeeks/782175.html

  7. Introduction and question

    Date: 09/26/05 (PHP Community)    Keywords: php, mysql, html, database, sql

    Hi everyone! I've slowly been teaching myself php and mysql over the past few months, but it's slow going, and I tend to learn better from someone teaching me something than I do from a book. I finally got the bright idea today (after having been on LJ for how long? lol) to look for a php help community, and lo and behold, I find you! :D If anyone could help me, I'd be very appreciative.

    Here's the situation: I'm trying to build forms that will gather the information provided, check to make sure that everything necessary is included, and either redirect to an error page or a success page as needed. The html form looks like this (obviously without the spaces):

    < form action="add_entry.php" method="post">
    Subject: < input type="text" name="subject" />
    Text: < textarea rows=6 cols=60 name="text">< /textarea>
    < input type ="submit" name="add_entry" value="Add Entry" />
    < /form>

    add_entry.php looks like this (again, without the spaces):


    include('common.php');
    if(isset($formname) && $formname == 'add_entry'){
    if($subject != '' && $description != ''){
    $dbh=mysql_connect ($host, $user, $pass) or die
    ('I cannot connect to the database because I do not like you' . mysql_error());
    mysql_select_db ($database) or die('I could not find the database you are searching for');
    $query = "INSERT INTO journal
    SET dateadd = NOW(),
    subject = '$subject',
    message = '$description'";
    mysql_query($query);
    mysql_close($dbh);
    $redirect = 'success.html';
    }
    else{
    $redirect = 'error.html';
    }
    }
    else{
    $redirect = 'error.html';
    }

    < html>
    < head>
    < meta http-equiv="Refresh" content="1;url=< ?php echo $redirect ?>" />
    < /head>
    < /html>

    My problem is that it never seems to go through the mysql query and always redirects to the error page. I know that the query is good--I've checked it through phpMyAdmin--so I'm thinking it has something to do with the isset.

    Any help would be greatly appreciated! :D

    Source: http://www.livejournal.com/community/php/347463.html

  8. sendfile in PHP

    Date: 09/26/05 (PHP Community)    Keywords: php, web, apache

    Howdy folks.

    The Apache webserver has the ability to use the sendfile() syscall to efficiently send static files. This feature copies from the file to the socket at the kernel level and is thus very efficient. I'm currently writing an app in PHP which will need to efficiently send a large file to the user without clients being able to request the file directly.

    My question is whether there's any way to get at this from PHP land. I see the virtual() function which causes Apache to perform a subrequest, but I'm hoping there's a way to do it without incurring the subrequest overhead. I've also seen PHP's readfile() function and its friends, but I suspect (please correct me if I'm wrong) that the copying between file and socket will then happen in PHP land.

    Alternative approaches are welcome too. :)

    Source: http://www.livejournal.com/community/php/347342.html

  9. HTACCESS

    Date: 09/26/05 (Web Development)    Keywords: php, html

    Dammit, I've read up on this and htaccess file settings seem to be about the easiest god damn thing - except that mine doesn't work. All I want is for forum_redirect.html to redirect to index.php. That would require this, right?

    Redirect forum_redirect.html index.php

    and that's it, right? Every time I do it I get an error 500 and my whole site shits the bed.

    Suggestions?

    Source: http://www.livejournal.com/community/webdev/247663.html

  10. Java Leads Again; VB in Massive Decline

    Date: 09/29/05 (Java Web)    Keywords: php, programming, java

    According to TIOBE Programming Community Index Java is the leading programming language again, ahead of C and C++, its nearest rivals. Perl and PHP occupy 4th and 5th positions respectively attesting to the power of scripting languages. Within the .NET languages only C# appears likely to survive. VB has suffered large decline and is currently in 6th [...]

    Source: http://blog.taragana.com/index.php/archive/java-leads-again-vb-in-massive-decline/

  11. ASP.NET

    Date: 10/02/05 (Web Development)    Keywords: php, asp

    Hey guys, don't ever really post here, but read alot. I'm primarily a PHP developer and am looking to move into doing ASP.NET (preferably C# not VB) and was hoping maybe someone would have some ideas on some good resource sites that might help me get started in this direction. Thanks in advance.

    Source: http://www.livejournal.com/community/webdev/248776.html

  12. Function With Possible Race Condition

    Date: 10/03/05 (PHP Community)    Keywords: php

    Hi, everyone. I've written a library function that opens a file (for reading or writing) safely, including file locking and error reporting. It also retries a locked file a few times on the theory that any lock is likely to be released after only a second or two, and it's better to delay output for a couple of seconds (but then give the user something useful) than to just try once and then give up with an error message.

    Since this is a very low-level routine that I'll be relying on heavily in a variety of other projects later on, I want it to be really robust. Completely bulletproof would be nice, actually. And the function already works fine in the few low-traffic situations I've deployed it in; I'm not having any of the usual "why can't I get this to work?" problems. Instead, I'm concerned that there may be a possible race condition lurking in the space between the fopen() and flock() calls, and I'd like to get some other people's input about it. Here's the function code itself, with minimal comments to show the calling syntax and point out the area I'm concerned about:

    function safeopen ($filename, &$errmsg, $mode  = 'r', $lock = LOCK_EX) {
    
    # Required arguments are: file to be opened, and a variable that 
    # error messages will be placed in. Optional arguments are:
    # whether to open read-only or read/write, and the locking mode.
    
    # Will return a filehandle on success; on failure, returns false and
    # places an error string in the $errmsg variable.
    
    $retry_msecs = 250;
    $timeout_secs = 5;
    
    global $php_errormsg;
    
    $elapsed = 0;
    while (! $fh) {
    	# This will always fail the first time around.
    	if ($elapsed >= $timeout_secs * 1000) {
    		if (strlen($errmsg)) {
    			$errmsg = "Couldn't open file: ".$errmsg;
    		} else {
    			$errmsg = "Couldn't open file; no other error data available.";
    		}
    		return false;
    	}
    	$fh = @fopen($filename, $mode);
    	if (! $fh) {
    		$errmsg = $php_errormsg;
    		usleep($retry_msecs * 1000);
    		$elapsed += $retry_msecs;
    	}
    }
    
    # Note that there's a gap between the fopen() call in the previous
    # loop, and the flock() call coming up. This is what I'm worried about.
    
    while (! @flock($fh, $lock+LOCK_NB)) {
    	$errmsg = $php_errormsg;
    	if ($elapsed >= $timeout_secs * 1000) {
    		if (strlen($errmsg)) {
    			$errmsg = "Couldn't acquire lock on file: ".$errmsg;
    		} else {
    			$errmsg = "Couldn't acquire lock on file.";
    		}
    		return false;
    	}
    	usleep($retry_msecs * 1000);
    	$elapsed += $retry_msecs;
    }
    
    return $fh;
    
    }
    As you can see, I'm worried about the gap in execution between the fopen() and flock() calls. More specifically: since these two operations aren't being handled atomically, there seems to be a chance that one instance of safeopen() could open a file, and then before it managed to flock() it, a second instance might also open the same file.

    In that case, I'm unsure what happens when each instance attempts to lock the file. Does one of them succeed in locking, and then the other one fails? What happens if the first one only needs a shared lock, and then the second one wants an exclusive lock? Does it fail because the first one already has the shared lock?

    Note that in the last paragraph, "the first one" and "the second one" simply mean "whichever one first manages to acquire a lock" — I think there's no way to guarantee that the safeopen() instance that first started execution will also be the first one to acquire a lock. And I'm okay with that.

    Anyway, I think part of my worry here is that I'm somewhat new to file locking, and don't completely understand exactly how it plays out in marginal situations like this. So if someone can fill me in on the nitty-gritty details, I'd be most appreciative.

    Source: http://www.livejournal.com/community/php/348860.html

  13. onsubmit?

    Date: 10/03/05 (PHP Community)    Keywords: php, java

    Hi there,

    I'm trying to make a page that has two fields, email and name, and the corresponding submit button, that will send people to a different page after the submit button has been pressed. I want the user to be directed to a page to choose multiple mailing lists after they click the submit button. I tried fopen in the onsubmit and onclick parameters (which didn't work) and looked for an 'openurl' function or something like that in PHP, but can PHP do this? Do I need to be using Javascript? I feel like PHP must be able to handle it. If not, could you please let me know what can and how to do it?

    Source: http://www.livejournal.com/community/php/349160.html

  14. onsubmit? or not?

    Date: 10/03/05 (Web Development)    Keywords: php, java

    Hi there,

    I'm trying to make a page that has two fields, email and name, and the corresponding submit button, that will send people to a different page after the submit button has been pressed. I want the user to be directed to a page to choose multiple mailing lists after they click the submit button. I tried fopen in the onsubmit and onclick parameters (which didn't work) and looked for an 'openurl' function or something like that in PHP, but can PHP do this? Do I need to be using Javascript? I feel like PHP must be able to handle it. If not, could you please let me know what can and how to do it?

    Source: http://www.livejournal.com/community/webdev/249519.html

  15. PHP and Forms

    Date: 10/04/05 (PHP Development)    Keywords: php, java

    I'm after a bit of help with a complex form i have on my site. I am aware that this may actually be a Javascript issue, but i'm only "advanced beginner" in PHP, so i'm not too sure. hopefully if i explain my goal, someone can pooint me in the right direction, or offer up some code :)

    I have a form that has a row of drop-down menus, that when each one is selected and filled out, the variables should all amke up one long instruction. For example the first box might be numbers 1 to 10, the second box might be a list of fruit. by selecting the number (say 3) and then the fruit (say apples) '$var1 $var2' would eaqual '3 apples'. So, what i would like to happen is when a submit button is pressed, '$var1 $var2' is written to a textarea underneath the form, and '3 apples' would be shown in the textarea. But it doesn't end there! I'd also like the user to then be able to select another '$var1 $var2' combination, and upon submit have it add that underneath the first one in the textarea.

    And as a final piece, pressing a second submit button underneath the textarea will pass the texarea variable onto the next page of the form (which i plan to store in a hidden var). I can kind of figure out this final part, but it all depends onhow the other stuff is done i guess.

    I'm really hoping it isn't javascript, or at least not too much, heh. Any help or pointers? :)

    please, and thanks! :)
    paul.

    Source: http://www.livejournal.com/community/php_dev/60274.html

  16. session variable help?

    Date: 10/04/05 (PHP Community)    Keywords: php, mysql, sql, web, shopping

    Context: I'm working on a bare-bones shopping cart system and am using a session variable $cart to store cart items. $cart is an associative array holding item_id => quantity. To add an item to the cart, I'm calling the page with a url variable ?new=xx where xx is the item id. If the item id exists in the array, am incrementing it. If it doesn't exist, I create it and set the quantity to 1. In theory, anyway.

    Problem: Adding a new item to the cart produces the expected results, but if the page is called immediately after without the url variable, or with a url variable pointing to a different id, it increments the quantity of the item just added by one. It is also the case that when I call a separate checkout page with the display_cart($cart) function in it, the item quantity shows up incremented by one.

    (the following code will look very familiar if you've ever used PHP and MySQL Web Development)


    On the shopping cart page:

    if($new)
    {
        if(!session_is_registered("cart"))
        {
            $cart = array();
            session_register("cart");
        }

        if($cart[$new])
             $cart[$new]++;
        else
            $cart[$new] = 1;
    }

    if($save) //have tried commenting out this part, makes no difference
    {
        foreach ($cart as $item_id => $qty)
        {
            if ($$item_id == "0")
                unset($cart[$item_id]);
            else
                $cart[$item_id] = $$item_id;
        }
    }

    if ($cart&&array_count_values($cart))
        display_cart($cart);
    else
        echo "There are no items in your cart.";


    Display cart function:

    function display_cart($cart)
    {
        echo "

    ";
        echo "";
        echo "";
        echo "";
        echo "";

        foreach($cart as $item_id => $qty)
        {
            $item = get_item_details($item_id);
            echo "";
        }

        echo "";
        echo "
        < td align = center >
        < input type = hidden name = save value = true >
        < input type = image src = \"images/save_changes.jpg\" border = 0 alt = \"Save Changes\">
        
        
        ";
        echo "
    item nameqtyprice
    ";
            echo $item['name'];
            echo "
    ";
            echo "";
            echo "
    ";
            echo $item['price'];
            echo "
    &nbsp;&nbsp;
    ";
        echo "
    ";
    }


    I've done a bit of reading on how sessions work, but am still pretty confused by it. Is this black magic or am I just not going about this right? Any suggestions, including debugging techniques, would be appreciated. In the meantime, I'm just going to take a whole different approach to this cart, but I'd like to solve the mystery eventually.

    Thanks in advance.

    Source: http://www.livejournal.com/community/php/350281.html

  17. I'm dazzled.

    Date: 10/04/05 (PHP Community)    Keywords: php, html, apache

    form.html:

    < form action="script.php" method="post">
    < input type="text" name="user">
    < input type="submit" name="submit" >
    < /form>
    
    script.php:
    
    
    The script shows nothing no matter whether I use GET or POST. Maybe the problem is somewhere in PHP settings? I use Apache 2/PHP 4.3.9 on Darwin (Mac OS X 10.3). Could you please help me?

    Source: http://www.livejournal.com/community/php/349832.html

  18. PHP and Forms

    Date: 10/04/05 (PHP Community)    Keywords: php, java

    I'm after a bit of help with a complex form i have on my site. I am aware that this may actually be a Javascript issue, but i'm only "advanced beginner" in PHP, so i'm not too sure. hopefully if i explain my goal, someone can pooint me in the right direction, or offer up some code :)

    I have a form that has a row of drop-down menus, that when each one is selected and filled out, the variables should all amke up one long instruction. For example the first box might be numbers 1 to 10, the second box might be a list of fruit. by selecting the number (say 3) and then the fruit (say apples) '$var1 $var2' would eaqual '3 apples'. So, what i would like to happen is when a submit button is pressed, '$var1 $var2' is written to a textarea underneath the form, and '3 apples' would be shown in the textarea. But it doesn't end there! I'd also like the user to then be able to select another '$var1 $var2' combination, and upon submit have it add that underneath the first one in the textarea.

    And as a final piece, pressing a second submit button underneath the textarea will pass the texarea variable onto the next page of the form (which i plan to store in a hidden var). I can kind of figure out this final part, but it all depends onhow the other stuff is done i guess.

    I'm really hoping it isn't javascript, or at least not too much, heh. Any help or pointers? :)

    please, and thanks! :)
    paul.

    Source: http://www.livejournal.com/community/php/349535.html

  19. php interactive mode not working

    Date: 10/05/05 (Web Development)    Keywords: php

    Hi all. Does anyone here use PHP interactive mode at the command line? I'm trying to but it doesn't seem to work. I run php -a and it says Interactive mode enabled but then there's no prompt, and entering commands does nothing. I just downloaded and compiled php-4.4.0 with readline support, so I'm not sure why this doesn't work. Any suggestions?

    Source: http://www.livejournal.com/community/webdev/250467.html

  20. More problems with form action=

    Date: 10/04/05 (Web Development)    Keywords: php, browser

    Okay here's what I have:

    index page with 2 form fields (name,email)
    form declaration on this page is set to have action="mailing_lists.php"

    Why, then, does it take the form data once and return to the same page (index) after clicking submit once, but after filling out the fields again and clicking submit for the second time the browser goes to the specified mailing_lists.php? I want it to go there straight off, and take the $_POST['name'] and $_POST['email'] with it.

    Also: I'm trying to take the values of $_POST['name'] and $_POST['email'] and set them as the default value for two fields of the same type on the mailing_lists.php page, but value="$_POST does not work and it doesnt work if i enclose it in php tags either. (cant type them here or they parse)

    Any suggestions?

    Source: http://www.livejournal.com/community/webdev/250220.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