1. Very bizzare error

    Date: 07/14/06     Keywords: no keywords

    I just encountered the strangest error ever:

    Parse error: syntax error, unexpected ')', expecting T_PAAMAYIM_NEKUDOTAYIM in /home

    The code in question:

    ...
    else if(empty($password1) || empty($password2) || $password1 != $password2)
    	$message = "Password field may not be empty, and both fields must match";
    else if(ereg('[^A-Za-z0-9]', $fname) || empty($fname))
    ...
    


    The interpreter indicated the error was on the line with eregi - swapping the function calls (switch eregi with empty) eliminated the error. I have no idea what might have caused the error or even what it means. Any clues? Thanks.

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

  2. I was wondering

    Date: 07/14/06     Keywords: php, security, web

    I was wondering, just how many people write PHP to be console based "applications"? I find myself more and more using the language with the #!/usr/bin/php at the top to make it an executable script. I've found some great uses, one of my projects in fact is a SHOUTcast Automatic DJ system, customizable and modular of course, but it needs to be purely console based for the simple fact that the person I'm writing it for and myself want security and don't care about a web interface for this as it's unnessicary and very bloating. He'll want a web interface later, but I figure that can be done once I lay out the "application" in console, yanno? Back to what I was posting here about, I wanted to know how many people are using PHP in the command line environment as handwritten "app" to be able to do something or another. Curiosity gets the best of me, and if the response is high, I'll go ahead and post my library of functions i've found, written myself, compiled, and edited for CLE usage for everyone else to enjoy and use as well.

    XPosted

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

  3. This function could be better

    Date: 07/12/06     Keywords: php, database

    PHP -

    I've got this function. I know there's a better way to get the keys and values of arrays, but I can't think of it. Do you have any ideas?

    EDIT >>>

    Basically, the function takes two arrays in, and looks for keys in array2 (minus a frm_ prepending for form submission) that match keys in array1. I take the key from array1 and put the value of array2 in the output array.

    array2 is the $_SESSION array. array1 is an array of values from a database entry. Fields from a form are saved in the $_SESSION array so I can fill them in if there was an error on insertion.

    <<<


    function joinData($array1, $array2) {
    	$len1 = count($array1); //length of array 1 - speeds up loops
    	$len2 = count($array2); //length of array 2
    
    	$keys1 = array_keys($array1); //keys of array1
    	$vals1 = array_values($array1); //values of array 1
    
    	$keys2 = array_keys($array2); //keys of array2
    	$vals2 = array_values($array2); //values of array 2
    
    	$output = array(); //what we send out
    
    	for($i=0;$i<$len1;$i++) { //foreach element in array 1
    		for($j=0;$j<$len2;$j++) { //search each element in array 2
    			if( ($keys1[$i] == ereg_replace("frm_","",$keys2[$j])) ) { //until we find a key that matches after stripping frm_
    				$output[$keys1[$i]] = $vals2[$j]; // overwrite the value in array1; array2 takes precidence
    				break; // go to next element in array 1 - speeds up process (function is O(n log n), instead of O(n^2))
    			}
    		}
    	}
    
    	return $output; //send back the new values
    }

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

  4. Here's one for ya..

    Date: 07/12/06     Keywords: php, xml

    I'll *try* to make this short and sweet without getting into too much gory detail.

    I'm working on some Flash games (as best I can call them). Player results stay recorded in an XML file which is written and modified by PHP scripts, called by Flash when game results are in. The method Flash uses to send this data to PHP is via GET or POST. Upon receiving the data, the PHP script reads and writes to an XML file that's been reserved for that user. Easy enough so far. No worries. Got that mastered. But here's the trick...

    A script to access this PHP script must be in a visible directory in order for Flash to call it. In watered down terms, the user is calling it via Flash. But obviously I can't allow a user to DIRECTLY invoke the script. So how the heck can one decipher between Flash appropriately calling the script or a user trying to directly invoke what is basically the "gateway" to their stored XML info? I don't care so much as whether a user was able to see the XML, I just don't want illegal ability to write to it!

    Unlike my past encounters wish such issues, I don't believe there's an environmental variable to assist. For instance, HTTP_REFERER (which you shouldn't depend on anyway) has a null value when Flash invokes these scripts (hence one of the reasons it's not reliable. LOL)

    I'm sure this type of issue has been resolved somehow. But I can't seem to find any solutions online. Or maybe I'm trying to tackle this is a completely wrong way? Anyone ever had to deal with a similar issue?

    The only thought I've had is somehow coming up with some kind of scrambled identifier that PHP can send to flash at the beginning of the script that is then translated before any send() data is given to the PHP XML writing script. But those can easily be hacked through id comparisons if one is so inclined to use a packet sniffer :)

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

  5. Dreamhost and include()

    Date: 07/12/06     Keywords: security, apache

    I just switched over to Dreamhost, only to discover that they've disabled allow_url_fopen in the name of security. While I appreciate the effort, my last host apparently didn't care, and I rampantly abused includes. I still do it with my various Apache installs. Anyway, I've spent the last four hours de-including my site using the curl workaround available through the Wiki. I happened to enjoy my includes for debugging purposes, and adding four lines for each one was a bit burdensome (I enjoyed them that much).

    My question for you all is, why bother disabling allow_url_fopen? I just don't understand what all the worry is about. Thanks!

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

  6. strftime formatting issue

    Date: 07/11/06     Keywords: mysql, sql

    When I use the following:

    strftime('%C-%m-%d', $timestamp)

    where $timestamp for example is 1144788825, this is how it formats the date:
    Tue Apr 11 13:53:45 PDT 2006-04-11

    All I want is the 2006-04-11, because that matches the format of a date stored in MYSQL. Any idea why it is prepending it with the TUe Apr 11 and the full time etc. The manual on strftime is not helpful.

    Edit:I do realize that I can strip off the 10 characters at the end to get the part I want using substr()

    Thanks!

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

  7. function to round a number to the nearest specified increment?

    Date: 07/10/06     Keywords: no keywords

    is there at all a function that does this?

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

  8. mkfile?

    Date: 07/07/06     Keywords: php

    hello all.
    does anybody know , is it any function in php to create a file?
    thanks a lot

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

  9. Suggested forum

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

    Looking to install a PHP/MySQL based forum/BBS on my site. Haven't done anything with a forum since my days with Perl/CGI. What do you guys suggest for a good inexpensive & open source forum package?

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

  10. PHP on Windows...

    Date: 07/06/06     Keywords: php

    Is PHP on Windows (using IIS) a stable platform and is it supported by PHP?

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

  11. PHP errors within MySQL query

    Date: 07/06/06     Keywords: php, mysql, html, sql

    Howdy all.

    First of all, please see this post which I made to another community...

    http://community.livejournal.com/mysql/99541.html

    Yeah, I got confused with the code which I thought was MySQL problems but it turned out that it's actually PHP problems.

    Now, does anyone have any ideas what's wrong with the codes?

    Cheers.

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

  12. Stripping Links from a Page...

    Date: 07/06/06     Keywords: php

    I modified this script...

    http://www.phpfreaks.com/quickcode/Extract_All_URLs_on_a_Page/15.php

    To include a text area box so code could be copied and pasted into it...

    My modifications...
    http://www.MaskeProductions.com/scripts/geturls.txt

    It simply doesn't return anything, any ideas?

    Thanks!

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

  13. wysiwyg on a webpage?

    Date: 07/05/06     Keywords: blogging

    I am working on a blogging site. I would like to add a wysiwyg editor for users when they are creating a post. I've seen this around on a few sites like blogger and xanga. I've also played with writely. However, I'm not sure exactly how this are implemented and what the drawbacks are. Is there anyone out there that can share their experiences with this sort of thing?

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

  14. trying to destroy a cookie

    Date: 07/03/06     Keywords: php, java

    From PHP.net

    setcookie("dest", "", time() - 3600);

    dest is my cookie...

    But when I go to the next page and check my cookies ($_COOKIE), it's still there.

    Can you guys see anything wrong with that code? Suggestions?

    [update] strange setcookie ("dest", "somethingelse"); will change the value. But I need to destroy it, because the Javascript wont reassign a value.

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

  15. phpBB3

    Date: 06/30/06     Keywords: php, templates, software

    Note: This rant was prompted by phpBB's release of Beta1 of phpBB3... finally.

    I think phpBB is stupid for not switching over to Smarty with version 3 of the forum. They've essentially reinvented the wheel and I don't think they did as good of a job as Smarty does. They can't complain about supporting "existing templates" because there are none. On top of that, they could really use some unit tests.

    phpBB has gone down a long way since they first came out with phpBB 2. They used to be the leaders of forum software. Now they're playing catch up with everyone else. My own forums are so heavily modded that they already have more than half the features that phpBB3 will have. GameHavoc's forums, which recently were moved to vBulletin, already have all the features and then some that phpBB3 will have.

    I would switch over to vBulletin except I can't afford it, nor do I want to pay more for each site I might use it on.

    Are there no other very good PHP-based forum packages that don't cost money or have a code base that looks like it was originally made in PHP3 and never upgraded? I'm almost tempted to start making my own. There has got to be something out there that shows promise, though. Something with good coding practices and framework to back it up and make for easy development, deployment, and modification.

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

  16. Learning...

    Date: 06/29/06     Keywords: php

    Okay, I'm trying to work some PHP into a page I maintain, but I'm still very new to the concepts involved in PHP. This is probably really simple, but I can't find directions anywhere so I'm hoping all you PHP smarties can help. This is what I want to do:

    I want to write one document that defines a few variables and I want to call those variables from several other pages. How do you call a varible that is defined in another document?

    Thank you in advance!

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

  17. Joy.

    Date: 06/29/06     Keywords: php, programming, database

    I love how whenever I run into a problem and I post it here, it's always something that I know I should already know how to do.

    Seriously, this should be something really easy, right?

    The project that I'm working on, and really haven't had much time to deal with lately due to other stuff, is the same one that I'm always working on when I post here: A document tracking system for my mom's work.

    A whilie ago I ran into problems converting the system to an older version of PHP (it works fine now, in that regard), and now this.

    It works just fine, and does everything I want. I'm now trying to clean it up from slow and clunky code that was only used for the purpose of making sure the hard stuff worked (ironically, i had little to no problems doing the complicated logic stuff).


    So when bringing up the application, the user is given a form to fill out that essentially sends an e-mail, and has a vague e-mail feel to it anyway. The user has 10 drop-down menus for a maximum of 10 users. In the database, there is a table with all the users available. As a quick and dirty way of populating the list of names, I just wrote a small function that queries the database and plugs the names into the drop-down box. Well, right now, since there are 10 boxes, it does that 10 times. And it's SLOOOOOOW. My mom and I both knew that this wasn't how it was going to stay, it was just an easy way of testing the stuff that would.

    So, now that I'm backtracking slightly, I'm running into problems. What I want to do is pop the results of the query into an aray that mimics the structure of the table. Many rows, two columns. I set up a 2-d array, or tried to at least. The book I have isn't exactly clear on that topic, so I used what I thought I knew from regular programming languages and tried to apply that to this. Apparently it didn't work.

    I'm not sure why this doesn't work, so I'm just going to post the code used in here. Unfortunately, when I try and access the array with:

    $users = array(get_users());
    $num_of_users = count($users);
    for ($i=0; $i<$num_of_users; $i++)
    {
    echo " \n";
    }

    It doesn't do anything. So I don't really know what I'm doing wrong. I may be going about this way too hard. I wanted to just use the explode() function, but i couldn't think of how to get it to differentiate between what would go in one column versus another, and figured it would just plug it all into a 1-d array. So yeah, any help you can offer would be greatly appreciated.



    //This function pulls the users from the webusers table for use in choosing a recipient
    function get_users()
    {
    **Database Connect Information Removed**

    if (!$users_connect || !$db_select)
    {
    die("Problem connecting or selecting a database.");
    } //end if

    $query = "SELECT ename, eaddr FROM webusers ORDER BY ename";
    $result = mysql_db_query("test", $query);
    $num_of_users = mysql_num_rows($result);
    $users[$num_of_users][2] = array();
    $i = 0;
    while (list($ename, $eaddr) = mysql_fetch_row($result))
    {
    $users[$i][0] = $eaddr;
    $users[$i][1] = $ename;
    $i++;
    } //end while

    mysql_close();

    return($users);
    } //end get_users()


    Thanks so much!

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

  18. What is this doing?

    Date: 06/28/06     Keywords: no keywords

    Hello,
    in this statement what is the "&" doing?

    $globalref[] = &$this;

    Thanks

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

  19. cURL support/check

    Date: 06/23/06     Keywords: rss, xml

    i'm using cURL for the first time and just want to make sure i'm doing it right, i'm using it to grab an rss feed for processing.



    any help would be greatly appreciated, since this is my first time ever touching cURL

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

  20. php imap_mail() function

    Date: 06/23/06     Keywords: php

    hello all,

    why is my imap_mail() still being injected into my localhost mailserver despite my usage of imap_open() to sucessfully connect to a remote imap server?

    it's looking like i have to write my own fucntion to talk to the stream to build the email and send it. why would i have to do this, and why is it called imap_mail() when it's doing the exact same thing as mail() for me?

    i'm on PHP 4.2.2

    thanks in advance,
    -r

    Source: http://community.livejournal.com/php/464169.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