Re: [PHP] Date (Year) .. adding..
I like Tyler's solution. It is better to move the call to date() outside the loop. You only need to get the current year once, and then add one onto it each iteration. If you leave the call to date() inside the loop then it calculates the current date each time and that uses CPU power and time. Looking at it in list form, here is the difference: Original Solution - Set x to 0 while x is less than 20 calculate current year add value of x to year print year increase x by 1 New solution -- set x to 0 Get current year while x is less than 20 print year increase year by one increment x by 1 It's much faster to not have to call a function when it's not required, or in this case, where the value has already been computedespecially when the function is in a loop. :) On Tuesday 22 May 2001 09:30 pm, you wrote: > $x=0; > $year = date("Y"); > while($x < 20) > { > $year = $year+1; > print($year . "\n"); > $x++; > } > ?> > > Try that. > > Tyler > > > -Original Message- > > From: Jason Caldwell [mailto:[EMAIL PROTECTED]] > > Sent: Tuesday, May 22, 2001 11:20 PM > > To: [EMAIL PROTECTED] > > Subject: [PHP] Date (Year) .. adding.. > > > > > > I'm trying to figure out how to add to the year: > > > > for($x=0; $x<20; $x++) > > { > > $year = date("Y" + $x); > > print($year . "\n"); > > } > > > > I've tried several variations on the above and cannot get the year to > > come out. > > > > Any suggestions? > > > > Thanks > > Jason > > > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Using html templates
I'm using PHPLib as well and am not all that happy with it. It was working just fine until our host decided to upgrade to PHP4. After that, any values being inserted to HTML using templates that had dollar signs and values would not display! For example, if you said admission was $15.00 all that would display was .00!!! argh!! I emailed the phplib list and heard others had the same problem. The recent solution has been to modify your phplib code, unfortunately that keeps you from doing a flash upgrade of any future stuff. Which brings me to the next problem. IN a recent thread on the phplib mailing list titled "the future of phplib", a number of interesting points were brought up. In particular, the developers of PHPLib don't feel 'Templates' is the solution any longer, and they make the recommendation to the reader that they learn XML instead. There is a post regarding the future of PHPlib at this URL: http://www.geocrawler.com/lists/3/Web/195/125/4988613/ Unfortunately the site was down when I posted this email so I am unable to quote anything from it. You can make a decision regarding your current and future projects based on the statement made in that post. There are other template solutions, one being Fast Templates. I did use this at one time with success but ported to PHPlib because I required it for sessions in PHP3. There was also discussion about PHPLib Templates being faster. I am reading a book at the moment which lists two other template alternatives but I am unable to make suggestions based on what I've read so far Rob On Wednesday 23 May 2001 08:12 am, you wrote: > I am using libphp and quite satisfied with it. > http://phplib.netuse.de/ > > -- > Tolga 'thorr' Orhon > > ""Jamie Thompson"" <[EMAIL PROTECTED]> wrote in message > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > > what is the best way of using html templates to display data from a > > database? > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] stuck
I'm not 100% sure what you want to accomplish here, or why it is stuck on the last row, but I've made some observations. On Friday 17 August 2001 09:05 am, you wrote: session_start(); > session_register("address"); > session_register("city"); > session_register("state"); > session_register("zip_code"); > session_register("country"); > session_register("company"); > session_register("occupation"); > session_register("telephone"); > session_register("fax"); ->Session register variables that were supposed to have been passed by a form. For a piece of test code you may want to execute this to see what variables and values were passed. I think only UID and company have been passed via the uid select. echo 'From variables were:', print_r($HTTP_POST_VARS), ''; > > while ($row = mysql_fetch_array($result)) { > $uid = $row['uid']; > $address = $row['address']; > $city = $row['city']; > $state = $row['state']; > $zip_code = $row['zip_code']; > $country = $row['country']; > $company = $row['company']; > $occupation = $row['occupation']; > $telephone = $row['telephone']; > $fax = $row['fax']; > > $option_block .= "$company"; > } ->Here you've requested a bunch of info back from your query, but you only use uid and company in the option form, so you never actually pass the other info back to be registered by the session in your first lines. You could simplify with: $option_block = NULL; while ($row = mysql_fetch_array($result)) { $option_block .= ''.$row['company']. ''; } you may also want to do an echo in this block, or examine your html source to make sure you are getting back the values you request, and make sure that uid is unique to each row. ...if you need the other info you may want to do a query for it after the UID and company have been passed via the form on the second iteration, and then sess register them. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] $HTTP_REFERER
According to the spec: $HTTP_REFERER The address of the page (if any) which referred the browser to the current page. This is set by the user's browser; not all browsers will set this. So if it is set by the user's browser, it can be changed, or shut off. I believe there are programs out there that block that env var so people do not leave tracks within a site as well. Look at tucows.com for such programs. Typically, if a user went through 5 pages to sign up and is on the sixth page, I wouldn't worry about someone forging that too much. I'd be more worried about referrer not being set and then not allowing them to signup because of that. You can always set a variable like $PAGENUM in your code on the second last page and session register it, then check for it on the last page. If it exists, do your thing and destroy the session. If it does not exist, you can take the desired action. Combine this with the HTTP_REFERER and I would think you should be fairly safebut remember, the HTTP_REFERER could be empty, whereas the session var should be trusted as it is coming from your own site. On Friday 17 August 2001 09:34 am, you wrote: > > Thanks. But is using $HTTP_REFERER the most secure way of doing it? Or can > the $HTTP_REFERER be forged and thus gaining unauthorized access to the > forms? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] sessions
Hi Jeremy, session_destroy() should not destroy all your sessions. As per the manual: session_destroy() destroys all of the data associated with the current session. If you are having trouble with all your sessions being deleted in each run, it may be a problem with these php.ini file settings: session.gc_probability specifies the probability that the gc (garbage collection) routine is started on each request in percent. Defaults to 1. session.gc_maxlifetime specifies the number of seconds after which data will be seen as 'garbage' and cleaned up. You can find all the php session info at: http://php.net/manual/en/html/ref.session.html On Friday 17 August 2001 11:29 am, you wrote: > Hi there, I was wondering if a function such as session_close() or > session_stop() existed. You see, i've been using session_destroy and/or > session_unregister but the problem is that they unregister and/or destroy > ALL my sessions in my server folder. What I am trying to do is just stop > the session that is going on in that particular page? How can I do this? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Why lynx don't work with cron?
Hiya, I was waiting for someone to answer this question but it hasn't happened yet. I was using this a couple years ago to get a weather page from http after the ftp site with the raw text disappeared. Rest assured this has NOTHING to do with php and everything to do with lynx. I ran my script fine, then after I upgraded my system (I believe it was redhat 6.2) I started getting the error msg you got. After doing 'man lynx' and reading what I could, I gave up really fast and just reinstalled an older version of lynx cause let's face it, it was just a weather script that didn't warrant more than 20 minutes on. The message is basically saying "Hey, you're running me from a cron job and I can't find an ncurses terminal to output to!" I am assuming that's what it is but don't quote me :) You may want to spend a little time in the lynx docs, and then let us know when you find out :) Also, I'm not 100% sure that the script itself isn't running.try redirecting that from dev/null to writing to a file like /home/user/TEST.PHP and examine the contents. On Tuesday 21 August 2001 05:50 am, you wrote: > Hi, I'm trying the command "lynx -dump -nolog > http://localhost/script.php > /dev/null" on crontab > but I (httpd) receive an e-mail from "Cron Daemon" > saying that: > "Your terminal lacks the ability to clear the screen > or position the cursor." > > what should I do run my script with cron? > > thanks, > > Augusto > > ___ > Yahoo! GeoCities > Tenha seu lugar na Web. Construa hoje mesmo sua home page no Yahoo! > GeoCities. É fácil e grátis! http://br.geocities.yahoo.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] What does PHP stand for?
I believe that it was called Personal Home Page during version 2, and if I'm not mistaken, there was a contest (sorta) around the time 3 was released to find a new name. On Tuesday 28 August 2001 03:08 pm, you wrote: > On Mar 28 Ago 2001 19:52, John Meyer wrote: > > At 05:15 PM 8/28/01 +0228, you wrote: > > >It's actually a recursive acronym, like GNU: > > > > > > From the manual: > > > > > >"PHP, which stands for 'PHP: Hypertext Preprocessor', is an > > > HTML-embedded scripting language." > > > > > >J > > > > Am I making things up, or Did it stand for Perl Hypertext Preprocessor at > > one time? > > I always thought it meant Personal Home Page (isn't this right?) > > Saludos :-) -- Lactomangulation, n.: Manhandling the "open here" spout on a milk carton so badly that one has to resort to using the "illegal" side. -- Rich Hall, "Sniglets" -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]