1. Unusable column names?

    Date: 04/22/06     Keywords: php, mysql, database, sql

    Whilst using PHP and MySQL I noticed that I just get an error if I try to update (or do anything with) any field with the names unique and read in the database, forcing me to have to change the names in teh database.

    For instance, I'd get an error if I do this:


    At the moment to counter that, I've had to rename 'read' to 'opened' and it works fine, but I was just wondering if there was a way that I could actually use 'read' without getting an error.

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

  2. date/time formatting

    Date: 04/22/06     Keywords: php, mysql, database, sql

    In my MySQL database is a field realdate of type datetime. I am trying to convert that string (yyyy-mm-dd hh:mm) into a different format using PHP. The format I want is d/m/yy, h:mm which I gather from the manual is specified by this: j/n/y, g:i.

    Question is, how do I use PHP to format the string that MySQL outputs?

    Outputting the string without any manipulation produces the correct dates/times. When I try using date() all my dates read 1/1/70, 10:00. No difference when I tried using strtotime().
    $post_realdate_raw = $post_result['realdate'];
    $post_realdate = date("j/n/y, g:i", $post_realdate_raw);


    If anyone would be so kind as to explain what I'm doing wrong, I would be most grateful. TIA!

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

  3. A Stuck Newbie

    Date: 04/20/06     Keywords: php

    This is my front page and I know I'm missing something simple but I can't see it. This part where I have my content is suppose to look like this but it only works if I click on the home link, which is the link to get back to the index page.

    This is what I have in my content div under my template/index.php file.
    < ? php include ("$page.htm"); ? >


    Are they supposed to be separate files or the text is supposed to be actually there in the index.php file. I hope someone can help. Thanks in Advance.

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

  4. Sessions

    Date: 04/20/06     Keywords: no keywords

    I've gone through and made my own login system, so I'm familiar with how they generally work. Now, I've gone around and looked into making sessions safer, and I have a question.

    A concept I found pretty snazzy was that you don't start the session until after they successfully log into a site. That's awesome. My question is pretty quick: on all the following pages, what would the if statement look like to start the session? Would the following work?

    if($_COOKIE['name_of_session']) session_start()

    If so, is it still possible for an attacker to force a session to start if they know the name of your session cookie? On a site where registration is open to the public, is there any benefit from keeping sessions for logged-in users, when anyone can come and register?

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

  5. Broken function

    Date: 04/19/06     Keywords: html

    The following code is meant to take in a date of birth, and return the html needed for showing it selected in a form (for a profile edit page).

    As by the fact that I have posted it here, it isn't working. The syntax is correct but there must be a logic bug in it somewhere. Does anyone have a clue as to whats wrong with it?

    Thanks very much.

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

  6. Finding Primary Key From Table

    Date: 04/19/06     Keywords: php, mysql, database, sql

    So I looked at PHP documentation and a bit at SQL documentation but couldn't find anything.

    Is there a function to select the name of the primary key row in a table (MySQL database)?

    Thanks
    --Shamess

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

  7. Been a while since I needed some help...

    Date: 04/19/06     Keywords: php, database, sql

    ...and this is more of a "what's the best way to do this" question.

    I have a php script that's long and complicated. Essentially it does this (in number form, because it's easier to think that way):


    1. Queries an database DB1 for membership figures, based on an expiry date.
    2. Counts the number of rows found.
    3. For each row, the script:
      1. selects the first record from the table,
      2. stores the information in an array
      3. clears all records from a table in DB2
      4. loads the information from the array into the now-empty table in DB2.
      5. builds an email using PHPMailer using a single, never-changing email address
      6. passes the mail to a mail server for delivery. This mail server has the email address from the previous step loaded as a SQL distribution list, so it queries DB2 to get its information.
      7. Send an update query to DB1 to change the expiry date.
    4. At the end of all rows, the script again empties the table in DB2, so that no data is left that could cause problems later.


    Now, i've discovered that the script is faster than the mail server when it comes to SQL queries, and if I don't put in a usleep(); call in the script, the table will be emptied again by the time the mail server goes to check, which means the mail won't be delivered.

    I've set the max_execution_time to 60 seconds in php.ini and the usleep to 500000 (half a second), but I'm still not getting any more than 20-something emails sent before the script hits the max_execution_time. I plan on later setting up a cron job to hit the script at regular times (outside work hours, so the mail server is free for our particular mailouts).

    What's the best value for me to put into usleep to allow the mail server (MDaemon 7.0.1) to collect its information and then let the script go ahead as fast as possible -- you know, the most mail out in the shortest time possible?

    Just in case I've missed something, is there possible a better way to design this (for version 2)?
  8. Source: http://community.livejournal.com/php/441047.html

  9. PHP jobs resource?

    Date: 04/19/06     Keywords: php

    Does anybody know of any really good resources for finding a PHP development telecommuting job?

    (My resume is here: http://appleseed.sourceforge.net/resume/)

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

  10. beginner

    Date: 04/18/06     Keywords: no keywords

    Hi, I'm a beginner so my question might sound stupid, but I couldn't found the answer anywhere. Please help!

    I know I can append some content to a .txt file if I fopen(a+) it and then fwrite. But how could I change/overwrite part of a .txt file, or delete one line of it? I couldn't find a function that'll do the job.

    For example, if I have a file called "a.txt", and it looks like:
    This is the first line| Sencond sentence
    This is the second line| 4th sentence.

    How can I
    find and change "4th" into "fourth"?
    delete the first line and write in another line?

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

  11. Looking For A Mid-Level Introduction To Object-Oriented Programming In PHP

    Date: 04/17/06     Keywords: php, programming, java, shopping

    I'm a reasonably-experienced PHP programmer, but aside from minor tweakings in JavaScript and PERL, PHP's the only language I know. I'm redesigning my core shopping cart, and as such I'd really like to learn how Object-Oriented programming works, since I think that refactoring the back end to create, say, user objects and cart objects and inventory objects so forth would be much easier to maintain.

    Unfortunately, the OO books and pages I've found tend to break down into two rough categories:

    • "Hi, you know the fine details of object-oriented programming, so here's a bunch of complex PHP syntax that you will barely understand!"
    • "These are the basic ideas behind PHP Object-Oriented programming, but I will give you no code aside from a single class, when in practice you apparently never use isolated classes."
    I've read up on the basics and even a lot of design patterns... But can anyone recommend a book/site that explains how you'd put together several classes to create a functioning object-oriented program with classes that interact, explaining in practical terms (and plain English) the difference between, say, this->function() and this::function()?

    I need the power. And the help.

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

  12. PHP installation

    Date: 04/17/06     Keywords: php, mysql, sql, hosting, apache

    Hello,
    I have just recently contracted a Virtual Private Server account with a large hosting company. So far everything has gone pretty smoothly. I installed mysql and PHP and everything is running as it should. However when I installed PHP there was an option screen for me to choose what I wanted to install PHP with. I remember specifically choosing mysql support. However now when I try to run some of my pages I get this error:
    Call to undefined function: mysql_connect() in /usr/local/apache/htdocs/config.php on line 52

    Which tells me that the mysql functions were not installed.

    So to my question. How do I confirm that its not installed? If its not installed how do I install it?

    Thanks.

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

  13. PDFs

    Date: 04/16/06     Keywords: php, html

    I have a client that wants to my team to create a dynamic index of PDFs. I have never worked with PDFs and PHP before. One task is converting the PDFs to HTMl...

    If you guys can share any tips with working with PDFs I appreciate it.

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

  14. Random number from string

    Date: 04/15/06     Keywords: no keywords

    So far all I've needed is to use rand(1,10) if I want a random number, but now I need to produce a random number between one and ten, not including 2. How could I do this?

    --Shamess

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

  15. password/sequential pattern checking

    Date: 04/14/06     Keywords: php

    The Boss has noticed that a number of users have single-character or sequential passwords, and is unhappy about it. so i need to do something to force these users to change their passwords, and ensure their new password isn't 'z' or '1234' or whatever. anyone have any ideas on how to check this? enforcing password length is easy enough, but how can i check for sequential patterns? this has to apply to both '12345', 'abcde', etc., and preferably apply to sequences that don't necessarily start at the beginning ('efghi', '56789').

    php wasn't compiled with cracklib and i'm not sure that accomplishes what i'm going for anyway. i guess what i'm looking at is breaking the password down into characters and then looping through, comparing each character to the previous one, or something like that.

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

  16. have you seen this function

    Date: 04/12/06     Keywords: php

    I have an an array/object/whatever with vars in it:

    $foo->bar
    $foo->stuff
    $foo->somethingElse

    ...you get the idea. I want to make a local copy of all the variables in this array/object, so I can read the data without having to do "$foo->" first all the time.

    someFunc( $foo );

    ...and now I *should* be able to do $bar, $stuff, $somethingElse and have valid copies of what was stored in $foo. I could have sworn there was a built-in PHP function to do this, but I'm not able to find anything in the docs. Does anyone know it?

    Thanks.

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

  17. Running php code inside mysql calls

    Date: 04/11/06     Keywords: php, mysql, database, sql

    I'm trying to parse PHP code that is echoed from a MySQL database. Right now, it just prints the php code onto the page--how exactly would I parse this code to actually run? For example, my function would be:

    function image($imagename,$imagealign,$imagecaption)
    { echo "
    $imagecaption
    "; }


    And I want it to parse this out everytime I'd call the code, using (Keeping in mind that this is stored as text in a MySQL database--which plainly prints the italicized code rather than parses it)

    Also, how do I get the filename of my current file? Say I'm at http://blahblahblah.com/blah/info.php and I want just "info.php" rather than "blah/info.php"--what code snippet would I use?

    Thanks!

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

  18. Grabbing E-mail Addresses by the Horns

    Date: 04/10/06     Keywords: no keywords

    Okay... here's the problem.

    I am trying to build a function that will read a string, find all of the @'s in said string, and then pull out and assign the e-mail addresses to a variable, stopping when it hits a space or a comma.

    For example:

    email1@get.me,email2@get.me,email3@get.me,email4@get.me

    or:

    email1@get.me email2@get.me email3@get.me email4@get.me

    Does anyone know which functions I should start looking at first? I'm at a bit of a lose on something that seems very simple.


    $email = preg_split("/[\s,]+/", $raw_email);

    $i = 0;
    $findme = "@";
    $final_array = array();
    $limit = count($email);

    for($i;$i<$limit;$i++){
    if(strpos($email[$i], $findme) === false){
    }else{
    $elist = array($email[$i]);
    $final_array = array_merge($elist, $final_array);
    }

    }

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

  19. Charts And Graphs

    Date: 04/10/06     Keywords: no keywords

    Hello,

    I was wondering if anyone can recommend an easy way to create pie charts and graphs
    it looks like there are many options already out there, so one shouldn't have to reinvent the wheel
    Hotscripts list
    but I was wondering if any of you have found something both simple to use with a nice, clean appearance that you could recommend

    thanks

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

  20. PHP works in a .PHP file but not when it's in a .HTM file

    Date: 04/10/06     Keywords: php, html, apache

    This is driving me nuts! I know it's going to be something really simple, but I just can't work it out.

    Backstory: I've got a fresh install of Fedora FC5 on my server (the previous hard drive went pffzt) and I'm trying to get my WordPress blog running again.

    The problem is I can't seem to get PHP working properly. I've created a tiny HTM test file which doesn't show the PHP content, and yet it's working fine as a pure PHP file.

    I'm adamant the problem must be in the HTTP config but I just can't see what's wrong. How do I tell Apache to process PHP within an HTML file?


    (httpd.conf has virtually all the default settings - I've only added my site info but I've not changed/added/removed any LoadModule lines or anything else like that.)

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

  21. xpath not working, subscription to mailing lists weirdness

    Date: 04/09/06     Keywords: php, html, xml, web, linux, spam, apache

    Hi there.

    I'm trying to load an XHTML file as a DOMDocument, and get its text using xpath to find the node. Something's going wrong somewhere, but I can't figure out what.<br /><br /><a name="cutid1"></a><br />I've used xpath a number of times before, from xslt (Xalan and MSXML2) and C++ (libxml2, Xerces and MSXML2), so I thought I had a good idea of what I was doing. The test case I've got this down to (from reading the PHP docs for <a href="/go.php?http://uk.php.net/manual/en/print/function.dom-domxpath-evaluate.php">DOMXPath->evaluate()</a> and <a href="/go.php?http://uk.php.net/manual/en/print/function.dom-domxpath-query.php">DOMXPath->query()</a> is pretty short.<br /><br />The first file is pretty simple - it's just the data file for the second one to load.<br /><br /><b>page1.php</b><br /><pre> <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <shtml xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Title

    Body



    The second is the one that does the work.

    page2.php
    
    
    
    
    Home page.
    
    
    query($path, $context);
    
            $obj = new ReflectionObject($list);
            print("

    Search from \"" . $context->nodeName . "\" for \"" . $path . "\" (" . $obj->getName() . ")

    \n"); print("
      \n"); for ($i = 0; $i < $list->length; ++$i) { print("
    • " . $list->item($i)->nodeName . "
    • \n"); } print("
    \n"); } $dom = new DOMDocument(); $dom->load("page1.php"); print("

    Document Element node name: " . $dom->documentElement->nodeName . "

    \n"); pathsearch($dom, $dom, "/html/head/title"); pathsearch($dom, $dom, "/"); pathsearch($dom, $dom->documentElement, "/"); pathsearch($dom, $dom, "/*"); pathsearch($dom, $dom, "/html"); pathsearch($dom, $dom, "//html"); pathsearch($dom, $dom->documentElement, "."); pathsearch($dom, $dom->documentElement, "./*"); pathsearch($dom, $dom->documentElement, "./head"); pathsearch($dom, $dom->documentElement, ".//head"); pathsearch($dom, $dom->documentElement, ".//head/*"); pathsearch($dom, $dom->documentElement, ".//head/title"); pathsearch($dom, $dom->documentElement, ".//head//title"); ?>


    I get an empty nodelist for the first pathsearch(), which is the one I'm looking for.

    The second and third calls to pathsearch() check that I can actually access the root node, and get a non-empty list, as expected.

    Call 4 ("/*") finds "html", but 5 and 6 ("/html" and "//html") find nothing. An empty result for "//html" is very odd, considering "/*" finds an "html" node.

    Calls 7-13 try finding other nodes starting from the documentElement() (/html) just in case it doesn't like calling without a context. Of these, only 7 and 8 ("." and "./*") succeed with non-empty results. However the results I get are exactly what I'd expect ("html" and {"head", "body"} respectively) which leaves me even more confused as to why all the others are failing.

    Any help here would be appreciated. Even just reproducing my results would be good, so I know it's not just my setup that's b0rked.

    (I'm running php 5.1.2 with libxml 2.6.23 on apache 2.0.55 on linux 2.6.15. More system info can be provided if necessary)


    I originally tried to subscribe to the php-general mailing list to ask this question there, but haven't been able to, and have had no reply from php-list-admin@lists.php.net or postmaster@lists.php.net.


    I've sent a couple of requests, both from the website and via email, to subscribe to php-general@lists.php.net. Each time I've got the "confirm subscribe to php-general@lists.php.net" reply and replied to it. Each time, I've replied using both of the methods they suggest, but have received nothing since. No "welcome to the list" message, no list messages, no bounces, nothing. I've checked by spam folder, and it's not getting filed there.

    So, I tried emailing php-list-admin@lists.php.net which is supposedly staffed by people. I did that on March 31 and again on April 4. Nothing. No replies, no bounces, nothing.

    So, on April 7 I tried emailing postmaster@lists.php.net. Again nothing.

    Does anyone know WTF is going on over there? Why the hell don't they answer their goddamn email? I've been polite, and I've asked just for some kind of reply to let me know that someone is at least reading my messages. Even a "We're not going to help you" would be more useful that goddamn silence.

    So, does anyone else know if they are just a bunch of useless fucktards, or what?

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