Re: [PHP] php get rss tag using DOM
Michael A. Peters wrote: Rodgerr wrote: Morris-25 wrote: Hi, I am trying to write a programme to read a rss xml file. ... ... scan anyone tell me how to get the url attribute? I wrote some codes similar: $doc = new DOMDocument; $doc->load($myFlickrRss); $r = $doc->getElementsByTagName('media:content'); for($i=0;$i<=$r->length;$i++) { $node = $r->item($i); if ($node->hasAttribute('url') { $url[] = $node->>getAttribute('url'); } } That should give you an array called $url of all the url attributes in the nodes. $url[] = $node->>getAttribute('url'); should be $url[] = $node->getAttribute('url'); and don't forget to validate it before spitting it back out on a page somewhere ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php get rss tag using DOM
Rodgerr wrote: Morris-25 wrote: Hi, I am trying to write a programme to read a rss xml file. ... ... scan anyone tell me how to get the url attribute? I wrote some codes similar: $doc = new DOMDocument; $doc->load($myFlickrRss); $r = $doc->getElementsByTagName('media:content'); for($i=0;$i<=$r->length;$i++) { $node = $r->item($i); if ($node->hasAttribute('url') { $url[] = $node->>getAttribute('url'); } } That should give you an array called $url of all the url attributes in the nodes. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] is there a way to get more info about *why* the initial (DB PEAR) connect to db is failing?
On Jul 3, 2009, at 7:31 PM, Govinda wrote: my code: require 'DB.php'; // $db=DB::connect('db_program://user:passw...@hostname/database'); if (DB::isError($db)) { die("Can't connect: " . $db->getMessage ()); } is returning: "Can't connect: DB Error: connect failed" Any advise to find out WHY this is failing? (Note: I am fairly new to PHP, and brand spanking new at anything db- related with PHP.) thanks, Govinda -- P.S. I realize this had probably been covered countless times (best step by step advice how to troubleshoot the first connection to a mysql db), so i first did try to search the php list archives, here: http://marc.info/?l=php-general&w=2&r=1&s=db+connect&q=b and I am apparently missing something because when I input "failed db connection" at the top, in the search box, then it returns posts all over the map, and also takes out the middle word in my search string (so now it is just "failed db"). Why is that? I also searched for "failed database connection" which does not change my search input, but still the posts I found did not give me enough clue to stop me from posting here now. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php It's usually a simple thing since there are only 3 parameters so it's something that you have likely mis-spelled or input in the wrong order. It's not rocket science to figure it out, the docs are clear about how it works. But a likely guess maybe that you need to connect via localhost instead of the full domain name. $db=DB::connect('mysql://metheuser:myp...@localhost/mydatabase'); Bastien Sent from my iPod -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php get rss tag using DOM
Morris-25 wrote: > > Hi, > > I am trying to write a programme to read a rss xml file. > > ... > > ... > > scan anyone tell me how to get the url attribute? I wrote some codes > similar: > > > $doc = new DOMDocument; > $doc->load($myFlickrRss); > > $r = $doc->getElementsByTagName('media:content'); > for($i=0;$i<=$r->length;$i++) { > > // help here > > } > > Hi. Our site http://rssphp.blogspot.net http://rssphp.blogspot.net is working on providing possible solutions to the problem with different parsing methods in PHP. It's worth to have a look at the options. -- View this message in context: http://www.nabble.com/php-get-rss-tag-using-DOM-tp21901033p24330531.html Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Browser Alert
Hi gang: I just wasted a day trying to figure out why a standard html form using enctype='multipart/form-data" wasn't uploading images as it should in Safari. Sometimes it would work and sometimes it wouldn't. Sometimes I would get the spinning "loading X" of death in the address-bar and sometimes it would simply work and upload. No changes in code, just it works sometimes and it doesn't other times. This really had me stumped. Then I tried other browsers, such as FireFox and Opera and they worked every time. This is a Safari problem. So, if you're having problems with Safari 4.0 on Mac OSX uploading files, you're not alone. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Writing to a file
> On Fri, Jul 3, 2009 at 06:01, Jason Carson wrote: >> Hello everybody, >> >> How would I go about writing stuff to a file but in between the >> tags? > > The current industry standard is a combination of text editor and > keyboard, but there are many options. > > More specifically, are you trying to write to a PHP file *with* > PHP? And if so, would this be the kind of file you're trying to write > (such as creating an automated installer with auto-config)? > > -- > > daniel.br...@parasane.net || danbr...@php.net > http://www.parasane.net/ || http://www.pilotpig.net/ > Check out our great hosting and dedicated server deals at > http://twitter.com/pilotpig > Yes, I am trying to write stuff to a file with PHP but in between the tags and without deleting what is already in the file. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] is there a way to get more info about *why* the initial (DB PEAR) connect to db is failing?
my code: require 'DB.php'; // $db=DB::connect('db_program://user:passw...@hostname/database'); $db=DB::connect('mysql://metheuser:myp...@www.mydomain.com/ mydatabase'); if (DB::isError($db)) { die("Can't connect: " . $db->getMessage()); } is returning: "Can't connect: DB Error: connect failed" Any advise to find out WHY this is failing? (Note: I am fairly new to PHP, and brand spanking new at anything db- related with PHP.) thanks, Govinda -- P.S. I realize this had probably been covered countless times (best step by step advice how to troubleshoot the first connection to a mysql db), so i first did try to search the php list archives, here: http://marc.info/?l=php-general&w=2&r=1&s=db+connect&q=b and I am apparently missing something because when I input "failed db connection" at the top, in the search box, then it returns posts all over the map, and also takes out the middle word in my search string (so now it is just "failed db"). Why is that? I also searched for "failed database connection" which does not change my search input, but still the posts I found did not give me enough clue to stop me from posting here now. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Writing to a file
Jason Carson wrote: > Hello everybody, > > How would I go about writing stuff to a file but in between the > tags? > > Example, say I have config.php as follows... > > > $hostname = "localhost"; > $database = "database"; > $username = "username"; > $password = "password"; > > ?> > > How would I go about adding stuff at the end of the file, but before the > ?> tag? > The way I've done this in the past is to use an array. Then I can include the file, change the array and then var_export() to the file: //config.php 'localhost', 'database' => 'database', 'username' => 'username', 'password' => 'password', ); //file that does the changing writing "; file_put_contents('config.php', $content); -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] cannot figure out permissions for fopen/fwrite
Mari Masuda wrote: > Yes, currently the tmp folder (or any folders in my Apache htdocs > folder) is not accessible to the web due to the Mac's built-in firewall > set to block all incoming traffic except network time and something > installed by Adobe when I installed CS4 (e.g., Photoshop, InDesign, > etc.). However, I was wondering what the normal technique is for > writing files if the script that does the fopen/fwrite is located on a > production server that IS on the web. It occurred to me that I could > create a 777 folder outside of the web root so that it would not be > accessible on the web even if the script was running on a production > server, but I wasn't sure if that was a good or bad idea. > > On Jul 2, 2009, at 17:59, Waynn Lue wrote: > >> The tmp folder isn't accessible from the web though, right? Someone >> would first have to get access to your server for that. >> >> On 7/1/09, Mari Masuda wrote: >>> >>> On Jul 1, 2009, at 12:54, Shawn McKenzie wrote: >>> Mari Masuda wrote: > On Jul 1, 2009, at 12:20, Shawn McKenzie wrote: > >> Shawn McKenzie wrote: >>> Mari Masuda wrote: Hello, This is probably a dumb newbie question. I am running PHP 5.2.5 and Apache 2.2.8 on my Mac Book Pro OS X 10.4.11. I compiled PHP and Apache from source a while ago (as opposed to using the built-in web server that is included w/ Mac OS X). I have written the below PHP whose purpose is to read an existing comma separated (CSV) file and save the data into a text file that I can later copy and paste from into my website content management system. The problem is that on my Mac, I cannot seem to figure out what permissions I need to set in order to make the input CSV and the initially non-existant output text file readable and writable by Apache/PHP. I have Googled and come across many pages about different ways to set permissions and different permissions to set but none of the ways suggested that I tried seemed to work for me. As a temporary solution, I uploaded my PHP file to a Windows 2003 server running Apache and PHP and it worked flawlessly (and makes me suspicious that there is some huge security hole with the Windows box since it was able to execute with no permissions modifications). Any tips would be greatly appreciated. Thanks! Mari --- start my code --- >>> $in = fopen("/Applications/apache/htdocs/wp-php/wp.csv", "r"); $out = fopen("/Applications/apache/htdocs/wp-php/tableToCutAndPaste.txt", "w"); $counter = 0; fwrite($out, "\n"); while(($data = fgetcsv($in)) !== FALSE) { $paperNumber = $data[0]; $authors = $data[1]; $title = $data[2]; $filename = $paperNumber . ".pdf"; if(($counter % 2) == 0) { fwrite($out, "\n"); } else { fwrite($out, "\n"); } fwrite($out, ">>> href=\"http://www.example.com/workingpapers/getWorkingPaper.php? filename=$filename\">$paperNumber\n"); fwrite($out, "$authors\n"); fwrite($out, "$title\n"); fwrite($out, "\n"); $counter++; } fwrite($out, "\n"); fclose($in); fclose($out); ?> --- end my code --- >>> >>> What are the permissions on /Applications/apache/htdocs/wp-php/ ? >>> >>> Apache needs write permissions on that dir in order to create >>> the file >>> tableToCutAndPaste.txt. >>> >>> It's probably not a secure idea to give write permissions to >>> that dir, >>> so maybe create a subdir of tmp and change those permissions >>> (one way): >>> >>> mkdir /Applications/apache/htdocs/wp-php/tmp >>> chmod a+w /Applications/apache/htdocs/wp-php/tmp >>> >> >> Also, turn on error reporting so that you can see the exact >> problem. It >> may not be what you think. >> >> -- >> Thanks! >> -Shawn >> http://www.spidean.com > > > Thanks for the suggestions. I added the following lines to the > very top > of my code: > > error_reporting(E_ALL); > > mkdir("/Applications/apache/htdocs/wp-php/tmp", 0777, true); > chmod("/Applications/apache/htdocs/wp-php/tmp", "a+w"); > > and I also changed the line where it tries to open the file to > write to > to go to the new directory: > >
Re: [PHP] php-general mail server on blackhole list
On Fri, Jul 3, 2009 at 10:52, The Doctor wrote: > 13 RCVD_IN_JMF_BL RBL: Sender listed in JMF-BLACK > [216.92.131.4 listed in hostkarma.junkemailfilter.com] > > truns up in my spamc test. > > Please fix! I've processed the removal from their erroneous blacklist, but in the future, please report things such as this to webmas...@php.net, as the traffic on each individual list usually overshadows such reports. Thanks, Doc. -- daniel.br...@parasane.net || danbr...@php.net http://www.parasane.net/ || http://www.pilotpig.net/ Check out our great hosting and dedicated server deals at http://twitter.com/pilotpig -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php-general mail server on blackhole list
13 RCVD_IN_JMF_BL RBL: Sender listed in JMF-BLACK [216.92.131.4 listed in hostkarma.junkemailfilter.com] truns up in my spamc test. Please fix! -- Member - Liberal International This is doc...@nl2k.ab.ca Ici doc...@nl2k.ab.ca God, Queen and country! Beware Anti-Christ rising! Never Satan President Republic! The fool says in his heart, "There is no God". They are corrupt, and their ways are vile; there is no one who does good. - Ps 53:1 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] apc breaks pear::mdb2
Daniel Brown wrote: On Fri, Jul 3, 2009 at 07:00, Michael A. Peters wrote: Fatal error: Class 'PEAR' not found in /usr/share/pear/MDB2/Driver/mysql.php on line 876 Have you installed PEAR's PEAR module? I know it sounds a bit redundant, but see if that works for you. From the command line: pear install PEAR If it tells you that it's already on there, or if it installs but does not fix your problem, the next step is making sure that the include path contains the path to your PEAR files. If not, the class fails because the inclusion fails (and without looking at the source of the MySQL driver in the MDB2 package, my guess is that it's __autoload()'d rather than explicitly included, hence no message about a missing file). Yes, pear is installed [mpet...@athens ~]$ pear info PEAR About pear.php.net/PEAR-1.8.1 = Release Type PEAR-style PHP-based Package Name PEAR Channelpear.php.net SummaryPEAR Base System DescriptionThe PEAR package contains: etc. It works beautifully as long as apc.cache_by_default=0 I really only need it to cache DB queries and xml fragments. Caching includes (I assume what it is trying to do) would be nice but not if it does so in a broken manner. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] apc breaks pear::mdb2
On Fri, Jul 3, 2009 at 07:00, Michael A. Peters wrote: >> >> Fatal error: Class 'PEAR' not found in >> /usr/share/pear/MDB2/Driver/mysql.php on line 876 Have you installed PEAR's PEAR module? I know it sounds a bit redundant, but see if that works for you. From the command line: pear install PEAR If it tells you that it's already on there, or if it installs but does not fix your problem, the next step is making sure that the include path contains the path to your PEAR files. If not, the class fails because the inclusion fails (and without looking at the source of the MySQL driver in the MDB2 package, my guess is that it's __autoload()'d rather than explicitly included, hence no message about a missing file). -- daniel.br...@parasane.net || danbr...@php.net http://www.parasane.net/ || http://www.pilotpig.net/ Check out our great hosting and dedicated server deals at http://twitter.com/pilotpig -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Writing to a file
2009/7/3 Sándor Tamás (HostWare Kft.) : > The classic method is: > 1.) read the whole file into an array of strings. > 2.) search for the last line > 3.) insert a string BEFORE the last line. > 4.) write back the whole file to the same name > > Classic file handling does allow you to append to the end of a file, or > recreate as a whole. > Usually these types of editing must be done in memory, because file handling > does not allow inserts, deletes. Please don't top-post in threads. It makes them difficult to read for folks searching the archives. -- daniel.br...@parasane.net || danbr...@php.net http://www.parasane.net/ || http://www.pilotpig.net/ Check out our great hosting and dedicated server deals at http://twitter.com/pilotpig -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Writing to a file
On Fri, Jul 3, 2009 at 06:01, Jason Carson wrote: > Hello everybody, > > How would I go about writing stuff to a file but in between the > tags? The current industry standard is a combination of text editor and keyboard, but there are many options. More specifically, are you trying to write to a PHP file *with* PHP? And if so, would this be the kind of file you're trying to write (such as creating an automated installer with auto-config)? -- daniel.br...@parasane.net || danbr...@php.net http://www.parasane.net/ || http://www.pilotpig.net/ Check out our great hosting and dedicated server deals at http://twitter.com/pilotpig -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sessions
Hi, > .. This is precisely what I do, albeit my file is called config.php, and not init.php. Not that it makes a jot of difference. This file is used to setup the environment, so that way everything I commonly need is available simply by including one file. One thing to note though is that a database connection is not established by default. I used to get a lot of comment spam on my blog and because it was needlessly connecting to the database, it was bringing down the server. So now I simply use something like this to quickly and easily get a reference to a database object: $db = getDatabase(); Wunderbar. -- Richard Heyes HTML5 graphing: RGraph (www.rgraph.net - updated 3rd July) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Writing to a file
Jason Carson wrote: > How would I go about writing stuff to a file but in between the > tags? > http://www.php.net/file_put_contents -- Paul http://www.paulscott.za.net/ http://twitter.com/paulscott56 http://avoir.uwc.ac.za -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] apc breaks pear::mdb2
Michael A. Peters wrote: php 5.2.10 apc 3.0.19 With apc enabled, pear package mdb2 breaks with following error: Fatal error: Class 'PEAR' not found in /usr/share/pear/MDB2/Driver/mysql.php on line 876 disabling apc and site works just dandy again. ; Enable apc extension module extension = apc.so ; Options for the apc module apc.enabled=1 apc.shm_segments=1 apc.optimization=0 apc.shm_size=64 apc.ttl=7200 apc.user_ttl=7200 apc.num_files_hint=1024 apc.mmap_file_mask=/tmp/apc.XX apc.enable_cli=1 apc.cache_by_default=1 apc.stat=0 Changing apc.cache_by_default to 0 also fixes it, so it seems it has a problem with how it caches pear/mdb2 stuff. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Writing to a file
Jason Carson wrote: Hello everybody, How would I go about writing stuff to a file but in between the tags? Example, say I have config.php as follows... How would I go about adding stuff at the end of the file, but before the ?> tag? IMHO that's kind of dangerous. Better to have an xml file - and read it into a DOM object via DOMDocument. Then you can add things to the DOM by making them children of the config node - and write the whole dom back to file. That way your web app does not have write permission to a file that gets executed, and you can potentially cache the DOMDocument object in memory so it doesn't have to read from file every page load to get your settings (not tried that yet myself but I don't see why you couldn't). -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] apc breaks pear::mdb2
php 5.2.10 apc 3.0.19 With apc enabled, pear package mdb2 breaks with following error: Fatal error: Class 'PEAR' not found in /usr/share/pear/MDB2/Driver/mysql.php on line 876 disabling apc and site works just dandy again. ; Enable apc extension module extension = apc.so ; Options for the apc module apc.enabled=1 apc.shm_segments=1 apc.optimization=0 apc.shm_size=64 apc.ttl=7200 apc.user_ttl=7200 apc.num_files_hint=1024 apc.mmap_file_mask=/tmp/apc.XX apc.enable_cli=1 apc.cache_by_default=1 apc.stat=0 Last one I added after seeing this: http://pecl.php.net/bugs/bug.php?id=15356 but that's not my problem from the apc.php - apc.cache_by_default1 apc.coredump_unmap 0 apc.enable_cli 1 apc.enabled 1 apc.file_update_protection 2 apc.filters apc.gc_ttl 3600 apc.include_once_override 0 apc.max_file_size 1M apc.mmap_file_mask /tmp/apc.BJhspx apc.num_files_hint 1024 apc.report_autofilter 0 apc.rfc1867 0 apc.rfc1867_freq0 apc.rfc1867_nameAPC_UPLOAD_PROGRESS apc.rfc1867_prefix upload_ apc.shm_segments1 apc.shm_size64 apc.slam_defense0 apc.stat0 apc.stat_ctime 0 apc.ttl 7200 apc.user_entries_hint 4096 apc.user_ttl7200 apc.write_lock 1 Any suggestions about what configuration is borking pear? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Writing to a file
The classic method is: 1.) read the whole file into an array of strings. 2.) search for the last line 3.) insert a string BEFORE the last line. 4.) write back the whole file to the same name Classic file handling does allow you to append to the end of a file, or recreate as a whole. Usually these types of editing must be done in memory, because file handling does not allow inserts, deletes. SanTa - Original Message - From: "Jason Carson" To: Sent: Friday, July 03, 2009 12:01 PM Subject: [PHP] Writing to a file Hello everybody, How would I go about writing stuff to a file but in between the tags? Example, say I have config.php as follows... How would I go about adding stuff at the end of the file, but before the ?> tag? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Writing to a file
2009/7/3 Jason Carson : > Hello everybody, > > How would I go about writing stuff to a file but in between the > tags? > > Example, say I have config.php as follows... > > > $hostname = "localhost"; > $database = "database"; > $username = "username"; > $password = "password"; > > ?> > > How would I go about adding stuff at the end of the file, but before the > ?> tag? Remove the ?> tag - it's not required if it's the last thing in the file. -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Writing to a file
Hello everybody, How would I go about writing stuff to a file but in between the tags? Example, say I have config.php as follows... How would I go about adding stuff at the end of the file, but before the ?> tag? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sessions
2009/7/3 Ashley Sheridan : > On Friday 03 July 2009 09:41:40 Tom Chubb wrote: >> 2009/7/3 Luke >> >> > 2009/7/3 Daniel Brown >> > >> > > On Thu, Jul 2, 2009 at 23:27, Jason Carson wrote: >> > > > Hello all, >> > > > >> > > > Do I have to add session_start() at the beginning of every page so >> > > > that the $_SESSION variables work on all pages or do I use >> > > > session_start() >> > >> > on >> > >> > > > the first page and something else on other pages? >> > > >> > > Yes, unless you're using session autoloading. Also, in most >> > > cases, you will only need to call session_start() once (before >> > > referencing $_SESSION), even if $_SESSION is accessed in an included >> > > file. >> > > >> > > -- >> > > >> > > daniel.br...@parasane.net || danbr...@php.net >> > > http://www.parasane.net/ || http://www.pilotpig.net/ >> > > Check out our hosting and dedicated server deals at >> > > http://twitter.com/pilotpig >> > > >> > > -- >> > > PHP General Mailing List (http://www.php.net/) >> > > To unsubscribe, visit: http://www.php.net/unsub.php >> > >> > Some people have a file called init.php, which would contain >> > session_start(); as well as other things that need to be done every page >> > load (connect to the database perhaps?) and they just 'require' that at >> > the top of every page. >> > >> > -- >> > Luke Slater >> > http://dinosaur-os.com/ >> > >> > :O) >> >> Never thought of that. Sounds like quite a good idea. >> Can anyone tell me if there's any reason for not doing that, even on pages >> that do not require session data? >> Or perhaps use an htaccess file to server side include a file file to all >> files under an admin folder or something and another to destroy the >> session. I'm thinking of smaller, low-traffic sites. >> I know people are going to say, if they're small sites, why can't you only >> start sessions on the relevant pages but it sounds like it could work well >> for me. > > > It's easier to maintain if you use one include file like Luke said. You won't > get much overhead from a call to session_start() on a page that doesn't use > sessions. It's also worth noting that every call to session_start() will result in the expiry time of the session being updated. Not calling it for pages that don't use the session could lead to the session expiring if the user doesn't hit a page that uses it for a while. -Stuart -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sessions
2009/7/3 Ashley Sheridan > On Friday 03 July 2009 09:41:40 Tom Chubb wrote: > > 2009/7/3 Luke > > > > > 2009/7/3 Daniel Brown > > > > > > > On Thu, Jul 2, 2009 at 23:27, Jason Carson > wrote: > > > > > Hello all, > > > > > > > > > > Do I have to add session_start() at the beginning of every page so > > > > > that the $_SESSION variables work on all pages or do I use > > > > > session_start() > > > > > > on > > > > > > > > the first page and something else on other pages? > > > > > > > > Yes, unless you're using session autoloading. Also, in most > > > > cases, you will only need to call session_start() once (before > > > > referencing $_SESSION), even if $_SESSION is accessed in an included > > > > file. > > > > > > > > -- > > > > > > > > daniel.br...@parasane.net || danbr...@php.net > > > > http://www.parasane.net/ || http://www.pilotpig.net/ > > > > Check out our hosting and dedicated server deals at > > > > http://twitter.com/pilotpig > > > > > > > > -- > > > > PHP General Mailing List (http://www.php.net/) > > > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > Some people have a file called init.php, which would contain > > > session_start(); as well as other things that need to be done every > page > > > load (connect to the database perhaps?) and they just 'require' that at > > > the top of every page. > > > > > > -- > > > Luke Slater > > > http://dinosaur-os.com/ > > > > > > :O) > > > > Never thought of that. Sounds like quite a good idea. > > Can anyone tell me if there's any reason for not doing that, even on > pages > > that do not require session data? > > Or perhaps use an htaccess file to server side include a file file to all > > files under an admin folder or something and another to destroy the > > session. I'm thinking of smaller, low-traffic sites. > > I know people are going to say, if they're small sites, why can't you > only > > start sessions on the relevant pages but it sounds like it could work > well > > for me. > > > It's easier to maintain if you use one include file like Luke said. You > won't > get much overhead from a call to session_start() on a page that doesn't use > sessions. > > Thanks, > Ash > http://www.ashleysheridan.co.uk > Great, Cheers Ash, T -- Tom Chubb t...@tomchubb.com | tomch...@gmail.com
Re: [PHP] Sessions
On Friday 03 July 2009 09:41:40 Tom Chubb wrote: > 2009/7/3 Luke > > > 2009/7/3 Daniel Brown > > > > > On Thu, Jul 2, 2009 at 23:27, Jason Carson wrote: > > > > Hello all, > > > > > > > > Do I have to add session_start() at the beginning of every page so > > > > that the $_SESSION variables work on all pages or do I use > > > > session_start() > > > > on > > > > > > the first page and something else on other pages? > > > > > > Yes, unless you're using session autoloading. Also, in most > > > cases, you will only need to call session_start() once (before > > > referencing $_SESSION), even if $_SESSION is accessed in an included > > > file. > > > > > > -- > > > > > > daniel.br...@parasane.net || danbr...@php.net > > > http://www.parasane.net/ || http://www.pilotpig.net/ > > > Check out our hosting and dedicated server deals at > > > http://twitter.com/pilotpig > > > > > > -- > > > PHP General Mailing List (http://www.php.net/) > > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > Some people have a file called init.php, which would contain > > session_start(); as well as other things that need to be done every page > > load (connect to the database perhaps?) and they just 'require' that at > > the top of every page. > > > > -- > > Luke Slater > > http://dinosaur-os.com/ > > > > :O) > > Never thought of that. Sounds like quite a good idea. > Can anyone tell me if there's any reason for not doing that, even on pages > that do not require session data? > Or perhaps use an htaccess file to server side include a file file to all > files under an admin folder or something and another to destroy the > session. I'm thinking of smaller, low-traffic sites. > I know people are going to say, if they're small sites, why can't you only > start sessions on the relevant pages but it sounds like it could work well > for me. It's easier to maintain if you use one include file like Luke said. You won't get much overhead from a call to session_start() on a page that doesn't use sessions. Thanks, Ash http://www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sessions
2009/7/3 Luke > 2009/7/3 Daniel Brown > > > On Thu, Jul 2, 2009 at 23:27, Jason Carson wrote: > > > Hello all, > > > > > > Do I have to add session_start() at the beginning of every page so that > > > the $_SESSION variables work on all pages or do I use session_start() > on > > > the first page and something else on other pages? > > > > Yes, unless you're using session autoloading. Also, in most > > cases, you will only need to call session_start() once (before > > referencing $_SESSION), even if $_SESSION is accessed in an included > > file. > > > > -- > > > > daniel.br...@parasane.net || danbr...@php.net > > http://www.parasane.net/ || http://www.pilotpig.net/ > > Check out our hosting and dedicated server deals at > > http://twitter.com/pilotpig > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > Some people have a file called init.php, which would contain > session_start(); as well as other things that need to be done every page > load (connect to the database perhaps?) and they just 'require' that at the > top of every page. > > -- > Luke Slater > http://dinosaur-os.com/ > :O) > Never thought of that. Sounds like quite a good idea. Can anyone tell me if there's any reason for not doing that, even on pages that do not require session data? Or perhaps use an htaccess file to server side include a file file to all files under an admin folder or something and another to destroy the session. I'm thinking of smaller, low-traffic sites. I know people are going to say, if they're small sites, why can't you only start sessions on the relevant pages but it sounds like it could work well for me.
Re: [PHP] Timezone details
Manoj Singh wrote: Hi All, Is there any function in PHP which will provide me the details of any timezone such as current time, DST, offset etc. Thanks in advance, Manoj It's called date http://php.net/manual/en/function.date.php The manual page on the function tells you how to get all that plus other groovy information. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sessions
2009/7/3 Daniel Brown > On Thu, Jul 2, 2009 at 23:27, Jason Carson wrote: > > Hello all, > > > > Do I have to add session_start() at the beginning of every page so that > > the $_SESSION variables work on all pages or do I use session_start() on > > the first page and something else on other pages? > > Yes, unless you're using session autoloading. Also, in most > cases, you will only need to call session_start() once (before > referencing $_SESSION), even if $_SESSION is accessed in an included > file. > > -- > > daniel.br...@parasane.net || danbr...@php.net > http://www.parasane.net/ || http://www.pilotpig.net/ > Check out our hosting and dedicated server deals at > http://twitter.com/pilotpig > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > Some people have a file called init.php, which would contain session_start(); as well as other things that need to be done every page load (connect to the database perhaps?) and they just 'require' that at the top of every page. -- Luke Slater http://dinosaur-os.com/ :O)
[PHP] Timezone details
Hi All, Is there any function in PHP which will provide me the details of any timezone such as current time, DST, offset etc. Thanks in advance, Manoj