1. XML file never appears when I use FTP client but it's there

    Date: 01/12/08     Keywords: php, xml, security, web

    I have a file /home/me/xml/email.xml that is created via PHP running from within stub-executable (/xml folder only permits "cgi" user to write to it).

    Problem is that I normally use TCL to write XML files, but because of my need to use $_SESSION for security reasons, I am having to do the entire program in PHP.

    /home/me/xml/email.xml is there when I do echo file_get_contents('/home/me/xml/email.xml'); however, I can't SEE the file no matter what tool I use.

    Here is the code that creates the email.xml file:

    
    	if (!function_exists('submit_email')) {
    		function submit_email($sessionName = '') {
    			global $userPath;
    
    			if (is_file("$userPath/xml/email.xml")) $contents = file_get_contents("$userPath/xml/email.xml");
    			if (!$contents) { /* NEW CONTENTS */
    				// DON'T FORGET YOU CAN'T HAVE < OR > NEXT TO ? ANYWHERE IN PHP UNLESS IT'S A COMMAND BLOCK DELIMITER!
    				$contents = '<' . '?xml version="1.0" encoding="utf-8"?' . '>';
    			} else {
    			 	// YOU WILL HAVE TO LOB OFF THE  CLOSING TAG ELSE YOU WILL HAVE MALFORMED XML
    			 	$contents = preg_replace('/<\/emailalert>$/i', '', $contents);
    			}
    			$contents .= '';
    
    			// RE-INSERT INTO email.xml
    			$isSuccessful = true;
    			//@unlink("$userPath/xml/email.xml"); // FOR SOME REASON IT DOES NOT CLEAR OUT CONTENT USING 'w' OPTION
    			if (!file_put_contents("$userPath/xml/email.xml", $contents, 'w')) $isSuccessful = false;
    			if ($isSuccessful) chown("$userPath/xml/email.xml", 'ppowell');
    			if ($isSuccessful) $msg = exec("chown ppowell:users \"$userPath/xml/email.xml\"");
    			if ($isSuccessful) chmod("$userPath/xml/email.xml", 700);
    			if ($msg) print_r($msg);
    			if ($isSuccessful && !is_file("$userPath/xml/email.xml")) $isSuccessful = false;
    
    			// REMOVE SESSION (OPTIONAL) AND RETURN FALSE
    			if (!$isSuccessful) {
    			 if ($sessionName && isset($_SESSION[$sessionName])) unset($_SESSION[$sessionName]);
    			 return false;
    			}
    		
    			return true;
    		}
    	}
    
    


    This is very frustrating as I can't debug other issues taking place unless I am able to view email.xml other than printing it out on webpage (which is live = bad idea)

    Help!
    Thanks

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

  2. Self-calling loops

    Date: 01/07/08     Keywords: html

    I have a script that calls to itself, though it's initiated from a parent script. Each subsequent child record is indented x spaces for visual representation, but I'm having trouble resetting the value of the counter at certain points. Example:


    I have 5 records as so, and should look like this:

    Record 1
    -Subrecord 1
     -Sub Subrecord 1
    -Subrecord 2
    -Subrecord 3

    However, this is what my script currently shows:

    Record 1
    -Subrecord 1
     -Sub Subrecord 1
     -Subrecord 2 <- This should be to the left one more space
    -Subrecord 3



    //Get all top-level (parent) records here
    while ($row = $d->dbFetchObject($result)) {
     ..... html output here....
     $oddRow = ($oddRow) ? 0 : 1;
     if (db::hasChildren($row->id)) {
    	createMenuHierarchyTable($row->id);
    	$oddRow = ($oddRow) ? 0 : 1;
     }
    }
    
    function createMenuHierarchyTable( $pid, $depth = 1) {
      global $d, $oddRow;
    
      ...execute query here to get children...
      while ($row = $d->dbFetchObject($result)) { ?>
        echo str_repeat(" ", $depth) . 'L ' . $row->menu_item_title;
        $oddRow = ($oddRow) ? 0 : 1;
        if (db::hasChildren($row->id)) {
    	$depth += 1;
    	createMenuHierarchyTable($row->id, $depth);
    	$oddRow = ($oddRow) ? 0 : 1;
        } else
    	$depth--;	
    	}
        }
    }
    



    I'm not sure how to subtract from the $depth variable otherwise. It resets correctly by Subrecord 3.

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

  3. DATETIME

    Date: 01/06/08     Keywords: php, mysql, sql

    Hi,

    I'm not very experienced with PHP/MYSQL, so I'll try and keep this as simple as possible. :P


    I have dates stored in MySQL as DATETIME.

    In my script, I'm trying to get it to display all the results for week #. Week # being 1-52. (I know in PHP it's displayed with "W")

    ... I have no idea how to do this. :| That is, extract the "W" from the DATETIME.

    I'm guessing I might have to strtotime() it and then date() but then that confuses me because I'd have to be doing it in the calling query itself?

    Eep. Help much appreciated. :)

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

  4. Parse date from filename

    Date: 01/03/08     Keywords: no keywords

    I need help with creating a RegEx to parse a date from the filename.

    $filename = 'Foobar2007-09-12.pdf'

    preg_match('?(19|20)[0-9]{2}[- /.](0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])/i', $filename, $matches);

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

  5. Problem with GET method when updating database

    Date: 12/31/07     Keywords: php

    The script should show a list of stuff which could be changed if the checkbox is ticked and button "Edit" is submitted or deleted if button Delete is submitted.

    But for some reason it worls very strangely. First of all, it allows to change only last thing on the list. At that if checkboxes of previous stuff in the list are ticked it updates DB with the values of the last one. And if I put tick and submit delete button it doesn't work at all.

    What is the reason of such behaviour? How to fix it?

    main file





    edit_submit.php





    Text files are here:
    http://www.helpeks.ru/code.zip

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

  6. Weird PHP Issue

    Date: 12/30/07     Keywords: php, html

    I'm creating a new login script, which includes a lot of files (and the core file itself runs to well over a thousand lines).... But about two-thirds of the time, whenever I try to access my test page in Mozilla Firefox, the page refuses to load. Insead, I get a dialogue box that says, "Opening page package.user.php," which tells me that I have "chosen to open" the file. The file itself is named the same, which is worrisome, but if I download it and then open it up in either a text file or Zend Studio, the downloaded file is completely blank at 0kb. Which makes no sense, since package.user.php echoes things to the screen, so it's not merely saving the output as a static file.

    This happens well before the max_execution_time logout on this server (which is 30 seconds). Anyone have any idea why this is happening? (I'm using HTML Purifier, which includes about a hundred files as part of its script, but I don't think that's an issue. Then again....)

    Bueller? Bueller?

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

  7. $_SERVER['DOCUMENT_ROOT']

    Date: 12/28/07     Keywords: php, mysql, sql

    hello everyone. after a couple of training classes, i felt i was ready to repair my first php/mysql site. anyway, when i downloaded the site to my machine for testing. these little things started causing problems on my testing server:

    require_once ($_SERVER['DOCUMENT_ROOT'].'/Connections/foo_db.php');

    the $_SERVER['DOCUMENT_ROOT'] on the site, of course, takes you back to the root of the whole server and then gets the file from the folder you requested. on my testing server it goes all the way back to the C drive, i.e., it won't find: C:/wamp/www/Connections/foo_db.php because it's going too far back. is there any way to set up my testing server so it assumes a certain folder is the root? i don't feel like going through and changing all the requires and includes. thanks.

    x posted in php_mysql

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

  8. Multiple source files for PHP 5 class

    Date: 12/26/07     Keywords: php

    I was wondering, is it possible for a single PHP class to reside in several source files?
    I mean, let's say I have a class named AClass, which has 2 public functions - one in the file AClass1.class.php, and one in the file AClass2.class.php. Is it feasible? I tried playing around with it, without much success.

    Thanks in advance.

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

  9. Developer-friendly Hosting?

    Date: 12/22/07     Keywords: php, programming, mysql, software, database, sql, postgresql, web, hosting

    Hello Friends

    I am interested in exploring web programming via Lisp, Ruby on Rails, and several of the popular Python frameworks.

    Here are the features I am interested in:

    * Lisp hosting including access to web servers and/or mod_lisp
    * Ruby on Rails hosting
    * Python hosting
    * Configurable source control repository with public and private areas (SVN/Trac or better)
    * SSH access
    * MySQL or PostgreSQL database
    * PHP support (for third-party software packages)

    Has anyone here had similar needs? Would you recommend any particular hosting solution?

    Thanks,
    '[info]'jkndrkn

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

  10. Selectable DB Entries

    Date: 12/21/07     Keywords: no keywords

    I want to create a page for a friend that will show him various statistics about his DB usage. 

    I would like it to include a (relevant) portion of the last 5 entries.

    I want those entries to be clickable, and bring up a new window with all the information visible and ready to print. 

    My question:

    I thought I would just pass the KEY (for the clicked entry) along to a generic page that would pull the data down and format it.  (Passing it along in the page address) 

    Does that sound reasonable? 

    I’m wondering if there is a better way to pass the information? 

    I also wonder about hitting the DB twice for the same entry (once for the initial query and again for the full query).

    Thoughts?

    -Thanks!

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

  11. Latitude/Longitude converter

    Date: 12/20/07     Keywords: php

    Not sure if this is a php question or geography question, so bear with me..

    I store coordinates in this format:

    lat 32.802138
    long -85.228672


    Is there a way to convert coordinates submitted in this format:

    lat N 35 59 13
    long W81 17 27


    To the format I use in my system?

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

  12. Compiling PHP, having problems.

    Date: 12/20/07     Keywords: php, mysql, sql, apache

    Hey guys, not sure if this is entirely the right place, but I'm having issues compiling PHP. I downloaded the 5.2.5 source tarball to my CentOS box this morning, compiled with gcc using:

    ./configure \
    --with-apxs=/usr/local/apache/bin/apxs \
    --with-libdir=lib64 \
    --prefix=/usr/local/custom \
    --enable-bcmath \
    --enable-calendar \
    --enable-ftp \
    --with-gd \
    --with-jpeg-dir=/usr/local \
    --with-png-dir=/usr \
    --with-xpm-dir=/usr/X11R6 \
    --enable-magic-quotes \
    --with-mysqli \
    --with-mysql=/usr \
    --enable-discard-path \
    --with-pear \
    --enable-sockets \
    --enable-zip \
    --with-zlib \
    --enable-soap


    and got this when I ran make test:
    =====================================================================
    FAILED TEST SUMMARY
    ---------------------------------------------------------------------
    Bug #16069 (ICONV transliteration failure) [ext/iconv/tests/bug16069.phpt]
    iconv stream filter [ext/iconv/tests/iconv_stream_filter.phpt]
    Bug #41567 (json_encode() double conversion is inconsistent with PHP) [ext/json/tests/bug41567.phpt]
    =====================================================================


    Since the errors listed are not functions used in my php applications, I installed anyway and everything worked fine. I then realized that I had omitted '--with-openssl', which is needed for my SOAP client, so I recompiled with the additional argument and am now getting the following output from make test:

    =====================================================================
    FAILED TEST SUMMARY
    ---------------------------------------------------------------------
    Bug #16069 (ICONV transliteration failure) [ext/iconv/tests/bug16069.phpt]
    iconv stream filter [ext/iconv/tests/iconv_stream_filter.phpt]
    Bug #41567 (json_encode() double conversion is inconsistent with PHP) [ext/json/tests/bug41567.phpt]
    Bug #31422 (No Error-Logging on SoapServer-Side) [ext/soap/tests/bugs/bug31422.phpt]
    IPv6 Loopback test [ext/sockets/tests/ipv6loop.phpt]
    Test array_reverse() function : usage variations - assoc. array with diff. value for 'array' argument [ext/standard/tests/array/array_reverse_variation5.phpt]
    Test array_unshift() function : usage variations - assoc. array with diff values for 'array' argument [ext/standard/tests/array/array_unshift_variation5.phpt]
    Test vsprintf() function : usage variations - string formats with non-string values [ext/standard/tests/strings/vsprintf_variation8.phpt]
    =====================================================================


    Since I use array_reverse() and vsprintf(), I didn't install.

    Oddly enough though, I'm getting the same failed test results now whether or not I include the '--with-openssl' argument. I run make clean in between attemtps and have even re-downloaded the 5.2.5 source tarball. Same 8 errors. Has anyone run into this?

    I have not yet downloaded an older source, and I'd rather not if I don't have to

    Edit: By changing the --prefix=[PREFIX] to a directory that was empty, I was able to get the errors to go back to the original 3, which is good enough to get my SOAP client working over SSL. I'd still like to get this to compile without any failures, but for now I can at least start work on the project that requires SOAP/SSL.

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

  13. Shorthand Question

    Date: 12/18/07     Keywords: no keywords

    I think I saw someone reference this in a previous comment (my searching has not rewarded me an answer) so here goes.

    Let's say I want to see if $foo is or is not several things. Is there a way to say:

    if ($foo == "a", "b", "c") rather than if ($foo == "a" || $foo == "b" || $foo == "c")

    I know I could always make the options an array and see if $foo is in the array, but I thought I'd ask if the whole comma thing (or something like that where you just aren't typing $foo over and over) exists.

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

  14. random text

    Date: 12/17/07     Keywords: database, sql, web

    I have 15 random paragraphs of text, each a couple sentences long, nothing major. I want to display a random one on the main page of a website every time the page loads. I am not terribly concerned with the flexibility or expandability of this script, I just don't want it to slow anything else down... I once took down a sql server because I had way too many queries on a web page, and since then I've been a little paranoid about using tons of database-driven stuff. Then again if I just hard-code all the text into the script, my 500 byte script or whatever will be 10x the size it once was, since it'll have to load all the text.

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

  15. XML parsing woes...

    Date: 12/15/07     Keywords: php, mysql, xml, database, sql

    Okay, so while I'm relatively good with PHP, I'm not so good with PHP 4's XML handling, and I'm having some problems creating an XML parser that will read tag attributes (which I'm then putting into a MySQL database).

    I've tried a half-dozen different examples of parsers that others have done, and none seem able to pull the attributes out. I have no say in how it's structured, so I have to find a way to deal with it as is. My XML looks something like this:



       
          
             <br />            Blah blah blah...<br />         
             
                Big long description goes here.
             

             
                0000-00-00T00:00:00-0500
             

          

       




    Everything else parses fine, except those damn description attributes. They seem to just disappear into the ether.

    Anyone know of an easy way (outside of PHP 5, not an option in this situation) that I can get the info I need?

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

  16. apache + mod_ssl + virtualhosts = headaches

    Date: 12/14/07     Keywords: php

    this might or might not be php specific, but i'm posting it here because i figured someone might have seen this and figured out a fix.

    okay, so i think i found a "feature" of mod_ssl. mod_ssl is supposed to show _SERVER[HTTPS]=on|off at all times even if mod_ssl is not loaded, right?

    well, not if you have virtualhosts set up to share port 443, apparantly.

    i can see _SERVER[HTTPS] when i visit http://myhost/phpinfo.php and https://myhost/phpinfo.php, but if i go to https://myotherhost/phpinfo.php, i see no _SERVER[HTTPS] variable, but i DO get a secure page served by mod_ssl using the default certificate and no errors. my script is just unable to determine if the page was served through SSL or not due to the lack of _SERVER[HTTPS]

    is there something i need to do to get mod_ssl to export those vars to all of the virtualhosts? do i need to generate a new cert or something? any ideas?

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

  17. Non object Error?

    Date: 12/14/07     Keywords: tracker

    I have this in one of my object classes.

    static $errorTracker = NULL;
    public function __construct(){
    $this->errorTracker = ErrorTracker::getInstance();
    }

    protected function _isError($error){
    return $this->errorTracker->_isError($error);
    }



    And in the ErrorTracker class,

    public static function getInstance (){
    static $instance;
    if (!isset($instance)){
    $c = __CLASS__;
    $instance = new $c;
    }
    return $instance;
    }


    When this is run, I get:

    Fatal error: Call to a member function _isError() on a non-object

    Any idea why the ErrorTracker is falling out of scope? Thanks.

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

  18. Php backend setup?

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

    I want to make a site with adobe flex 2 as the GUI and then have php and mysql for the server side of things. I have been converting lots of my code over to take more advantage of OOP and am really liking the new feel of it all. Now my question is this, when actionscript/flex sends info to php, what is the best way to capture it?

    There are several ways I can think to set this up. I have several small files like login.php and getUser.php or even saveUser.php. ie, basically a php file for most of the commands I want to be able to deal with, but it seems like alot of files and kind of a waste of time. But then I could have one php file and pass in a mode variable which would allow that one .php file to have multiple funcitons. In the end, I do want all of the data verification to be done on the server side and the interface to do very little other than display the data. I want to be able to swap out the front end without having to redo the back end.

    This is my first time trying a N-Tier setup and just want to bypass any long and painful learning curves. Thanks.

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

  19. More RegEx

    Date: 12/12/07     Keywords: no keywords

    I had some assistance on here a week or so ago about replacing some text (which might be optional), and at first appeared to work. I modified slightly what I was was given to this result (the bullets you see are actually the output of the ascii equivalent):

    $rec = preg_replace('/•\s*(.*?)(?:\s*)?\s*(?:\r?\n)/i', '

    •$1

    ', $rec);

    So, when I use this regex in a query output to filter all records that may look like this:

    • Item 1

    • Item 2

    • Item 3



    it should turn into:

    • Item 1


    • Item 2


    • Item 3



    However, it seems to omit the first line search, so that I only get:

    • Item 2


    • Item 3




    Where in the regex can I change this so it doesn't omit anything?

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

  20. regex, match special char & one alpha

    Date: 12/11/07     Keywords: no keywords

    $x = " I?m having fun! ";
    $x = ereg_replace('[\?]', '\'', $x);

    echo $x = "I'm having fun!";


    $x = " I?m having fun! ";
    $x = ereg_replace('[\?m]', '\'', $x);
    echo $x = "I'' having fun!";


    I need to replace the question mark followed by a single alpha character. I don't understand how to match a ? followed by a character, as a group.

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