[PHP] Help. Floats turning into really small numbers? x.xxxxxxxxxxxxxxxxxxxxxxE-xx
I'm having trouble figuring out why subtraction of two floats are giving me a very small number. I'm thinking it has something to do with the internals of type casting, but i'm not sure. If anyone has seen this or can give me some suggestions, please. I have 2 variables that go through a while loop and are added/subtracted/ multipled. InvAmt and InvPay are shown as floats but when they are subtracted, they give me a really small number // code var_dump($InvAmt); var_dump($InvPay); var_dump($InvAmt-$InvPay); // output float(18.49) float(18.49) float(2.1316282072803E-14) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] [Q] mail() security
Eric, It sounds like you just need to do some reading on best practices of security when writing php code. It's pretty vast what one can do when trying to hack a php application and depending on what php server settings are set, you may need to do certain things. I'd suggesting reading / google php security and viewing pages like the following to answer your question. It may only answer your question in the long run, but there are many more things to know about besides htmlentities to make sure your application is secure. I actually need to do some reading about them. Once in a while http://www.devshed.com/c/a/PHP/PHP-Security-Mistakes/ Also events like the following are good to go to expecially if you can get your company to pay for them. http://www.osevents.com/page5.html? Eric Gorr wrote: Chris W. Parker wrote: Or in a less extreme case, your computer get hijacked and used to send spam because you used htmlentities() instead of strip_tags(). Well, this is why I asked the question to begin with. I am concerned (as everyone _should_ be) about such things and desire to do my best to prevent them. Now, as near as I can tell, strip_tags is the only thing one really needs to do to be safe. But, one can use htmlentities to potentially preserve useful text, if it is important to do so and still remain safe - with the downside being having a messier body then may be necessary. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help. Floats turning into really small numbers? x.xxxxxxxxxxxxxxxxxxxxxxE-xx - Narrowed it down!
Ok i've narrowed it down a little bit but still can't figure it out.. Here's the code and what I get for the output. Does anyone know what's going on? Can someone else run it on their computer and see if they get the same results? ?php $a = 17.00 * 1; $a+= 1.10 * 1; $a+= 0.32 * 1; $a+= 0.07 * 1; print $a.br; // 18.49 var_dump($a); // float(18.49) var_dump($a-18.49); // float(3.5527136788005E-15) ? Anthony Tippett wrote: I'm having trouble figuring out why subtraction of two floats are giving me a very small number. I'm thinking it has something to do with the internals of type casting, but i'm not sure. If anyone has seen this or can give me some suggestions, please. I have 2 variables that go through a while loop and are added/subtracted/ multipled. InvAmt and InvPay are shown as floats but when they are subtracted, they give me a really small number // code var_dump($InvAmt); var_dump($InvPay); var_dump($InvAmt-$InvPay); // output float(18.49) float(18.49) float(2.1316282072803E-14) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Tool to answer emails
I think what you are looking for is a combination of programs. A mailing list that customers can view answers of emails try mailman or smartlist. Perhaps just a mailint list would give you want you want. If you are looking for more of a trouble ticket program, or FAQ program there are serveral at freshmeat.net but haven't used many of them. Daniel Baughman wrote: Hi all, I am looking for a php tool that will provide email tracking and a web interface to an email box. Pretty much, we get lots of emails directed to an administrative email account (most of the valid emails) that need response. To the point that one person is getting over whelmed. It would be nice if someone had a tool already made that would check the box, download the email, mark the receipt time, then present them to be answered on a web site for employees, document the answer, etc. etc.. Anyone know of anything? Dan Baughman IT Technician Professional Bull Riders, Inc. 719-471-3008 x 3161 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help. Floats turning into really small numbers? x.xxxxxxxxxxxxxxxxxxxxxxE-xx - Narrowed it down!
btw, thanks for your response. I'm not sure as if I understand why. It's not like I'm using a very precise number when dealing with the hundreths place. Even without the multiplication the number gets messed up. eg. $a = 17.00; $a+= 1.10; $a+= 0.32; $a+= 0.07; print $a.br; // 18.49 var_dump($a); // float(18.49) var_dump($a-18.49); // float(3.5527136788005E-15) I'm just trying to add money amounts? Can I not rely on floats to do this? Richard Lynch wrote: Floats are NEVER going to be coming out even reliably. You'll have to check if the difference is less than X for whatever number X you like. Or you can look at something like BC_MATH where precision can be carried out as far as you like... But what you are seeing is to be expected. That's just the way computers work, basically. On Mon, April 4, 2005 5:07 pm, Anthony Tippett said: Ok i've narrowed it down a little bit but still can't figure it out.. Here's the code and what I get for the output. Does anyone know what's going on? Can someone else run it on their computer and see if they get the same results? ?php $a = 17.00 * 1; $a+= 1.10 * 1; $a+= 0.32 * 1; $a+= 0.07 * 1; print $a.br; // 18.49 var_dump($a); // float(18.49) var_dump($a-18.49); // float(3.5527136788005E-15) ? Anthony Tippett wrote: I'm having trouble figuring out why subtraction of two floats are giving me a very small number. I'm thinking it has something to do with the internals of type casting, but i'm not sure. If anyone has seen this or can give me some suggestions, please. I have 2 variables that go through a while loop and are added/subtracted/ multipled. InvAmt and InvPay are shown as floats but when they are subtracted, they give me a really small number // code var_dump($InvAmt); var_dump($InvPay); var_dump($InvAmt-$InvPay); // output float(18.49) float(18.49) float(2.1316282072803E-14) -- 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] Help. Floats turning into really small numbers? x.xxxxxxxxxxxxxxxxxxxxxxE-xx - Narrowed it down!
Thanks to everyone that helped. After further googling, bug 9288 had a good explanation of what was going on ( which is not a bug) http://bugs.php.net/bug.php?id=9288edit=3 I'll just include the answer for anyone that comes upon this tread on a search engine. [15 Feb 2001 2:55pm CET] hholzgra at php rot dot fot net short answer: never use floats or doubles for financial data! longer answer: the internal number format in modern computers is binary (base 2) and not decimal (base 10) for performance and complexity reasons while it is possible to convert decimal numbers into binaries and back this does not hold true for fractions something like 0.3 (decimal) would be a periodic binary fraction like 10/3 is 0.... in decimal this leads to loss of precision when calculation with decimal fractions as you have when storing currency values solution: if you just summ up values then you should store values in the smalest unit your currency has (pennies?) instead of what you are used to (Pounds?) to totally avoid fractions if you cannot avoid fractions (like when dealing with percentage calculations or currency conversions) you should just be aware of the (usually very small) internal conversion differences (0.27755575615629 in your example) or use the bcmath extension, although for monetary values you should go perfectly fine with using round(...,2) on your final results Anthony Tippett wrote: btw, thanks for your response. I'm not sure as if I understand why. It's not like I'm using a very precise number when dealing with the hundreths place. Even without the multiplication the number gets messed up. eg. $a = 17.00; $a+= 1.10; $a+= 0.32; $a+= 0.07; print $a.br; // 18.49 var_dump($a); // float(18.49) var_dump($a-18.49); // float(3.5527136788005E-15) I'm just trying to add money amounts? Can I not rely on floats to do this? Richard Lynch wrote: Floats are NEVER going to be coming out even reliably. You'll have to check if the difference is less than X for whatever number X you like. Or you can look at something like BC_MATH where precision can be carried out as far as you like... But what you are seeing is to be expected. That's just the way computers work, basically. On Mon, April 4, 2005 5:07 pm, Anthony Tippett said: Ok i've narrowed it down a little bit but still can't figure it out.. Here's the code and what I get for the output. Does anyone know what's going on? Can someone else run it on their computer and see if they get the same results? ?php $a = 17.00 * 1; $a+= 1.10 * 1; $a+= 0.32 * 1; $a+= 0.07 * 1; print $a.br; // 18.49 var_dump($a); // float(18.49) var_dump($a-18.49); // float(3.5527136788005E-15) ? Anthony Tippett wrote: I'm having trouble figuring out why subtraction of two floats are giving me a very small number. I'm thinking it has something to do with the internals of type casting, but i'm not sure. If anyone has seen this or can give me some suggestions, please. I have 2 variables that go through a while loop and are added/subtracted/ multipled. InvAmt and InvPay are shown as floats but when they are subtracted, they give me a really small number // code var_dump($InvAmt); var_dump($InvPay); var_dump($InvAmt-$InvPay); // output float(18.49) float(18.49) float(2.1316282072803E-14) -- 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
[PHP] Setting or Getting Relative Path for PHP Includes
Hey Folks, Hoping someone can aid me with a newbie-ish question. I often use PHP includes in my files to pull in assets, but I hard code the relative path to the root html directory for the sites that I'm working on in each file. Example below: ?php $path = '/home/virtual/sitename.com/var/www/html/'; //relative path to the root directory $inc_path = $path . 'code/inc/'; //path and folder the code includes folder is located $copy_path = $path . 'copy/'; //path and folder the copy is located ? I'd like to be able to set the relative path as a global variable from an external file so that I can modify one line of code to change the relative path across the site. This will allow me for easier coding in staging and development environments. What's the best way to do so? Can anyone provide a code example? Either that, or is there a way to call this variable from the server itself so that it's automatically -- and correctly -- set? Thanks, Anthony -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] apache2 php stability
I have read at various places on the web that Apache 2 and PHP running as a module isn't recommended for production sites. Does anyone here run PHP 4/5 and Apache2 in a high load production environment with success? If so, whats your configuration? Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] apache2 php stability
Apache2 is multithreaded and works better under higher loads with a smaller memory footprint. If you have 300 simul connections under apache 1.3 you need 300 forks. The same load under apache 2 runs under 300 threads. With Linux 2.6 threads are very lightweight and in terms of system resources very inexpensive to start. Under a high load spike Apache 2 would, in theory, respond better. Greg Donald wrote: On Mon, 29 Nov 2004 15:55:31 -0600, Anthony Gauda [EMAIL PROTECTED] wrote: I have read at various places on the web that Apache 2 and PHP running as a module isn't recommended for production sites. Does anyone here run PHP 4/5 and Apache2 in a high load production environment with success? If so, whats your configuration? I don't have any experiences to share with you about PHP5 and Apache2 except that I'm using them on a server at home so I can play with Mojavi 3. But I got a question for you.. What does Apache2 have that you need feature-wise that Apache doesn't have already? Just curious is all. :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] apache2 php stability
actually any distro with a 2.6 kernel should already have it. You can check by doing a getconf GNU_LIBPTHREAD_VERSION if it says NPTL .xx you have it... Greg Donald wrote: On Mon, 29 Nov 2004 16:21:22 -0600, Anthony Gauda [EMAIL PROTECTED] wrote: The same load under apache 2 runs under 300 threads. With Linux 2.6 threads are very lightweight and in terms of Are distros shipping with NPTL already? I saw a Gentoo thread on how to convert a system to use NPTL but peeps were having lots of glibc issues at the time. :( I'm using 2.6 in a couple places, desktops and dev servers, but have not tried NPTL yet. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Specifying Variable Document Path in PHP
Hey Folks, My first post to this list and forgive me if this is ground that's been trod before, but this has been bugging me for a bit. I'm developing a site that's going to be running on a staging environment and a production environment. Have a number of PHP includes in the production site that specifically call the file pathname (thus): ?php include '/home/production_site/public_html/pagename.php' ? The problem here is that the path will vary slightly depending on whether it's the staging server or production server. I'd ideally like to set a single global variable that can handle this so I don't have to hard-code paths across the site (as I'm doing now). Is there any easy way to accomplish this? Thanks in advance, Anthony -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] foreach()
Greetings, The following code is from Learning PHP5 [O'Reilly] on page 90. Example - 6.5: I get a: Warning: Invalid argument supplied for foreach() in c:\apache\htdocs\or_6.4.php on line 15 after submitting the form. I'm not sure why since the example uses the call to foreach() in which the array $lunch is passes through the call to retireve the values of the array Thank you for your help. TR form method=post action=eat.php select name=lunch[] multiple option value=porkBBQ Pork Bun/option option value=chickenChicken Bun/option option value=lotusLotus Seed Bun/option option value=porkBean Paste Bun/option option value=chickenBird-Nest Bun/option /select brbr input type=submit name=submit /form Selected buns: br ? foreach ($_POST['lunch'] as $choice) { print You want a $choice bun.br; } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] htmlentities()
Copied and pasted the following sample script from the php manual and this outputs: ... ?php $str = A 'quote' is bbold/b; echo htmlentities($str); ? .. // outputs: A 'quote' is bbold/b Not sure why the I am still getting the tags and spaces after the call to htmlentities(). Thank you for any help. TR -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] htmlentities()
Chris Shiflett wrote: View source, and I think you'll understand. Or, remove the call to htmlentities(). Chris .. Thank you all for your assistance. Best... TR ... ...when a browser sees lt, it prints out a character instead of thinking OK here comes an HTML tag. This is the same idea (but with a differnt syntax) as escaping a or $ charcater inside a double quoted string... ~[from Learning PHP5 [O'Reilly] page 102] ?php $str = I blove/b sweet tea and div class=\fancy\rice./div tea\n; echo $str; echo br; echo htmlentities($str); ? // Output in view source code: I blove/b sweet tea and div class=fancyrice./div tea brI lt;bgt;lovelt;/bgt; sweet tea and lt;div class=quot;fancyquot;gt;rice.lt;/divgt; amp; tea -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Does this beginner's book exist?
Chris Lott wrote in message: I am looking for a new text for my beginning PHP...[snipped] ... Besides Larry's book - which is excellent - try David Sklar's book called Learning PHP 5 (O'Reilly). Not too much on mySQL with PHP except for chapter 7 _however_ the whole book is grounded in the understanding of PHP syntax and constructs - if/else, loops, arrays, functions - then moves on to databases, cookies/sessions, forms and files. Clear, concise and with humor and if you like Chinese food great entrees for the array examples. Both books are very good. TR -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Does this beginner's book exist?
Chris Lott [EMAIL PROTECTED] wrote in message: I am looking for a new text for my beginning PHP and MySQL programming class. This class is for COMPLETE beginners who have never programmed before. I have used, in the past, PHP4: A Beginner's Guide and PHP for the World Wide Web (Visual Quicktart). (I will be using PHP4, at least until the Redhat Enterprise Server upgrades :) However, both of these books, while being well pitched towards beginners, also assume that register_globals is enabled, and while the former is more like a textbook (it has exercises and mini-quizzes) it doesn't do as good a job with the examples as the latter (which has no exercises). My students are distance education students, so little things like variable scopes can be very time consuming to help them with-- it would be nice if the text got it right :) Does a book for complete beginners exist that also demonstrates basic good programming practices, has decent examples, and perhaps exercises/quizzes (not as important as the first two)? c -- Chris Lott ... Besides Larry's book - which is excellent - try David Sklar's book called Learning PHP 5 (O'Reilly). Not too much on mySQL with PHP except for chapter 7 _however_ the whole book is grounded in the understanding of PHP syntax and constructs - if/else, loops, arrays, functions - then moves on to databases, cookies/sessions, forms and files. Plus, there are questions at the end of each chapter. Clear, concise and with humor and - if you like Chinese food - mouth watering entrees for the array examples. Both books are very good. TR -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] strcasecmp()
? $first_name = Hello; $second_name = Hello; if(strcasecmp($first_name,$second_name)) { echo words are equal; } else { echo words are not equal.; } ? .. In strcasecmp() - this comparison will return 0 - interpreted by PHP as FALSE - eventhough words are _equal_ so what will execute is words are not equal. whereas if the negation symbol of ! is inserted as in: ... ? $first_name = Hello; $second_name = Hello; if(!strcasecmp($first_name,$second_name)) { echo words are equal; } else { echo words are not equal.; } ? ... to read if the comparsion which is returned is not _FALSE_ excecute: words are equal. . Am I on the right track with this logic? Thank you. TR -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql_fetch_array()
Thank you Chris. My question was the call to mysql_fetch_array() will also return a result set without the additional argument constant as in: while ($row = mysql_fetch_array($sql)) {... // no constant is being used There are many times that I see that used in textbooks - without the constant - just the variable from the sql query as the argument. TR --- [This E-mail scanned for viruses by gonefishingguideservice.com] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] mysql_fetch_array()
When using mysql_fetch_array() is it necsessary to specify the second argument - meaning the constant of MYSQL_NUM or MYSQL_ASSOC? I have seen many examples where it is left out and it is coded: $row = mysql_fetch_array($sql); as opposed to $row = mysql_fetch_array($sql, MYSQL_BOTH); Thank you. TR -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] RSS / eregi_replace()
Greetings, I'm using an RSS feed from the New York Times and right now the a href link takes the user to the same window. I'd like the link to open in it's own window by using the target .html attribute. I was hoping that I could use the eregi_replace() call by inserting: a href=http://\\0;target=_blank\\0/a where it matches any character between the link/link string in the URL. However it is not working for me. Viewing the xhtml of thr NY Times feed below, there are many areas of links/links so I'm not sure whether this is the correct way to go. Any leads or assistance will be greatly appreciated. TR .. ? $string=linkhttp://www.nytimes.com/2004/08/03/national/03tape.html? ex=1249272000en=484f82ff258ab8c7ei=5088partner=rssnyt/link; // the string URL $pattern = ^(link.+/link)$; //match any character between the link and link $replace_pattern= 'a href=http://\\0;target=_blank\\0/a'; $new_string=eregi_replace($pattern,$replace_pattern,$string); echo $new_string; ? // snippet of NYTimes RSS feed linkhttp://www.nytimes.com/2004/08/03/politics/03intel.html?ex=1249272000; en=e061516bea792668ei=5088partner=rssnyt/link descriptionMuch of the information that led to the new terror alert was three or four years old, but even the dated evidence was troubling./description authorBy DOUGLAS JEHL and DAVID JOHNSTON/author pubDateTue, 03 Aug 2004 00:00:00 EDT/pubDate /item - item titleTape of Kennedy's Killing Is Getting Digital Analysis/title linkhttp://www.nytimes.com/2004/08/03/national/03tape.html?ex=1249272000e n=484f82ff258ab8c7ei=5088partner=rssnyt/link -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] RSS / eregi_replace()
Justin Patrin [EMAIL PROTECTED] wrote in message: Thanks, lots of good info here. It's nice to have all of the info at once. I don't know about eregs myself, but I'll try a preg solution: $new_text = preg_replace('!link(.*?)/link!', 'a href=\1 target=_blank\1/a', $text); Thank you. I tried the following: ? $text=linkhttp://www.nytimes.com/2004/08/03/national/03tape.html? ex=1249272000en=484f82ff258ab8c7ei=5088partner=rssnyt/link; $new_text = preg_replace('!link(.*?)/link!', 'a href=\1 target=_blank\1/a', $text); echo $new_text; ? The output in my browser is the URL with no link - and no target=_blank. http://www.nytimes.com/2004/08/03/national/03tape.html? ex=1249272000en=484f82ff258ab8c7ei=5088partner=rssnyt If you get a chance run the script through your server and see. I'm on apache. Any throughts? Many thanks for your time. TR -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php textbook
Reading Creating Interactive Websites with PHP and Web Services (Sybex) by Eric Rosebrock. I've found it a good textbook and wanted to get some feedback from the group about two things I noticed in most of the code throughout the book which has helped me. 1. The author separtares .html form from .php script by using many include() functions for the .html files. I have found that that helps from getting parse errors from the many escaped strings throughout the .html within a .php file if the coder can separate the .html markup from the backend script as much as possible. Kind of like CSS which can separate form from content. 2. The author makes use of many switch() constructs throughout the book as opposed to if / else. He brings in variables from query strings when the user submits the .html form to match the switch() contructs which then decides what action will follow. Anyway, I found the textbook a nice change in the way he presented his scripts and thought others would like to share any feedback if they have read or are reading the book. TIA TR -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] session looses variable
Hi, This is what is probably a newbie session problem. I've been having some trouble with sessions on php 4.0.6, I'm developing a website in which I don't have direct control over the server. Due to some other problems I created a test counter script to try to narrow down where the problem resides but no I'm sort of stuck. Here is the small counter script. session_start(); print_r($HTTP_SESSION_VARS); if (!session_is_registered('count2345')) { $GLOBALS['count2345'] = 0; echo create countbr; session_register('count2345'); } else { $count2345++; } echo br; echo session_id(); session_write_close(); When I refresh it will periodically loose the count2345 session variable and recreate the variable. At times it will also jump in value. Here are also the php configuration session settings. session.auto_start Off Off session.cache_expire 180 180 session.cache_limiter nocache nocache session.cookie_domain no valueno value session.cookie_lifetime 00 session.cookie_path // session.cookie_secure Off Off session.entropy_fileno valueno value session.entropy_length 00 session.gc_maxlifetime 1440 1440 session.gc_probability 11 session.name PHPSESSID PHPSESSID session.referer_check no valueno value session.save_handler files files session.save_path/tmp/tmp session.serialize_handler php php session.use_cookies On On Here is also the compile configuration which includes --enable-trans-sid './configure' '--disable-pear' '--enable-ftp' '--with-sybase-ct=/usr/local/freetds' '--enable-trans-sid' '--enable-force-cgi-redirect' Thank you -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Calendar math .... how to count in week days....?
The PEAR functions didn't seem to do what I was looking for. I built this function based on an idea given to me by Daryl Meese. After much trial and error, it actualy does what I need. My function is bassed on hours but you can easily change that. It will add or subtract days. - Anthony /* buisinessDays * Calculates a new date bassed on buisiness hours * vars: hours to adjust by, timestamp * returns: adjusted timestamp */ function businessDays($hours,$date) { // this function assumes $date is a business day $dayHours=7.5; // set how many hours are in a day // set the days we need to adjust by. there is a one day buffer $days=(abs($hours/$dayHours))+1; // weeks $adjust=604800 * floor($days / 5); // how many days are left over $remain=round($days % 5); // check for negative if ($hours0) { // check to see if we will land on a weekend, and make appropriate adjustment if (date(w,$date)=$remain) { $remain +=2; } // make the time adjustment, 8640 microseconds in a day, times the remaining adjustment $date -=($adjust +(86400 * $remain)); } else { // check to see if we will land on a weekend, and make appropriate adjustment if ((6-date(w,$date))=$remain) { $remain+=2; } // make the time adjustment, 8640 microseconds in a day, times the remaining adjustment $date +=($adjust +(86400 * $remain)); } return $date; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Calendar math .... how to count in week days....?
I've run into a bit of a problem, that I know has been dealt with before, but I don't know how to deal with it. Very simple, I have an application that needs to do calendar math and do it specifically on business days. I need to be able to add and subtract a number of days to only Monday though Friday. Seems simple enough, but I can't figure out how to do it. The only think I've come up with so far is to build a function that counts every day and checks to see if it's a weekend or not. This wouldn't be all that hard to do, but I'm wondering if there is a better way to do it? Anyone have a really efficient function to do this, I need to figure out a LOT of dates in this app. - Anthony -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] form textbox with search
Greets, The following code snippet receives data from a textbox named searchtext if the user types in a word. It then tries to match that word from the mysql database using: $searchtext = $_POST['searchtext']; if ($searchtext != '') { // Some search text was specified $where .= AND blurb LIKE '%$searchtext%'; } and adding on to the WHERE sql statement. If the user clicks the submit _without_ inserting a word, the whole database is output due to the basic select sql statement of: $select = 'SELECT DISTINCT merch.ID, merch.blurb, merch.price'; $from = ' FROM merch'; $where = ' WHERE 1=1 '; I am trying to work out a way to display a page that might say - Please enter a word if the user fails to insert a word in the textbox. Any help greatly appreciated. TR . ?php $dbcnx = mysql_connect('localhost', 'root', 'mypass'); mysql_select_db('sitename'); // The basic SELECT statement $select = 'SELECT DISTINCT merch.ID, merch.blurb, merch.price'; $from = ' FROM merch'; $where = ' WHERE 1=1 '; $lid = $_REQUEST['lid']; if ($lid != '') { // An lot is selected $where .= AND lid='$lid'; } $searchtext = $_POST['searchtext']; if ($searchtext != '') { // Some search text was specified $where .= AND blurb LIKE '%$searchtext%'; } ? table border=1 align=center trthClick for details/ththDescription/ththPrice/ththEdit/ththDelete/tht hPhoto/th/tr //etc. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] example from meloni not working
A basic ht counter script from Meloni's book on mysql (page 318). Not working for me. Every time I load the page the counter stays at zero. Thanks for help. TR .. ? $page_name=test1; $db=mysql_connect(localhost,root,'mypass); mysql_select_db(sitename); $sql = UPDATE test_track SET hits = hits + 1 WHERE page_name = '$page_name'; $sql2=SELECT hits FROM test_track WHERE page_name='$page_name'; $res=mysql_query($sql2); $hits = mysql_result($res,0,'hits'); ? html body h1You have been counted./h1 p The current number is ? echo $hits; ?/p /body /html . // mysql SCHEMA CREATE TABLE test_track( id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, page_name VARCHAR(50), hits INT ); INSERT INTO test_track VALUES(1,'test1',0); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] example from meloni not working
Thank you. TR -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] example from meloni not working
Thank you. TR -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] binary data in php
Lowell Allen [EMAIL PROTECTED] wrote in message: You might try using $HTTP_POST_FILES rather than $_FILES -- was necessary in my code recently. -- Lowell Allen ... Lowell, Thank you. I tried that in code below. Still - no dice. Any other thoughts? Best... TR ... ? if ($submit) { // connect to the database // (you may have to adjust the hostname,username or password) mysql_connect(localhost,root,mypass); mysql_select_db(mydb); $uploadfile = $HTTP_POST_FILES['form_data']['tmp_name']; $uploadname = $HTTP_POST_FILES['form_data']['name']; $uploadtype = $HTTP_POST_FILES['form_data']['type']; $uploaddesc = $_POST['desc']; // Open file for binary reading ('rb') $tempfile = fopen($uploadfile,'rb'); // Read the entire file into memory using PHP's // filesize function to get the file size. $filedata = fread($tempfile,filesize($uploadfile)); // Prepare for database insert by adding backslashes // before special characters. $filedata = addslashes($filedata); // Create the SQL query. $sql = INSERT INTO binary_data SET filename = '$uploadname', filetype = '$uploadtype', description = '$uploaddesc', bin_data = '$filedata'; $ok = @mysql_query($sql); if(!$ok)die('Database error storing the file:'.mysql_error()); $id= mysql_insert_id(); print pThis file has the following Database ID: b$id/b; echo br; echo a href=\getdata.php?id=$id\Click to view file/a; MYSQL_CLOSE(); } else { // else show the form to submit new data: ? form method=post action=?php echo $PHP_SELF; ? enctype=multipart/form-data pFile Description:br input type=text name=desc size=40 INPUT TYPE=hidden name=MAX_FILE_SIZE value=100 brFile to upload/store in database:br input type=file name=form_data size=40 pinput type=submit name=submit value=submit /form ?php } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] binary data in php
John W. Holmes [EMAIL PROTECTED] wrote in message: So what's the output? How do you know it's not working? If you're not getting an error, then your query is running and something is going in the database. Are you sure the problem isn't in how you're displaying the data? .. John, I know that there is no binary file upload to the table called binary_data in mysql database since I checked if there was a new entry through the command line after I submit. After I hit submit, the field that I inserted are blank. Any other thoughts? Thank you for your time. TR -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] binary data in php
Marek Kilimajer [EMAIL PROTECTED] wrote in message: You said register globals are off, didn't you? Where is the above variable set then? :) ... That was it. Many thanks Marek and others. Checking through the command line the file was uploaded to mysql database. However when clicking the getdata.php link - the file does not appear on the screen. The code is below. Thank you for your time. TR . //getdata.php ? if($_GET['id']==1) { @myql_connect(localhost,root,mypass); @mysql_select_db(sitename); $query = SELECT bin_data,description,filetype FROM binary_data WHERE id=1; $result = @mysql_query($query); $data = @mysql_result($result,0,bin_data); $description = @mysql_result($result,0,description); $type = @mysql_result($result,0,filetype); Header( Content-type: $type); echo $data.br; echo $description.br; } else { @mysql_connect(localhost,root,mypass); @mysql_select_db(sitename); $query = SELECT bin_data,description,filetype FROM binary_data WHERE id=$id; $result = @mysql_query($query); $data = @mysql_result($result,0,bin_data); $description = @mysql_result($result,0,description); $type = @mysql_result($result,0,filetype); Header( Content-type: $type); echo $data.br; echo $description.br; } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] file upload
In the following snippet, which uploads binary files to a mySQL database it works fine when Register Globals are set to ON. . mysql_connect(localhost,root,pass); mysql_select_db(adatabase); $data = addslashes(fread(fopen($form_data, r), filesize($form_data))); $result=mysql_query(INSERT INTO binary_data (description,bin_data,filename,filesize,filetype) . VALUES ('$form_description','$data','$form_data_name','$form_data_size','$form_data _type')); $id= mysql_insert_id(); print pThis file has the following Database ID: b$id/b; echo br; echo a href=\getdata.php?id=$id\Click to view file/a; mysql_close(); ... However, when I turn the Register Globals to OFF and insert a $_FILES[ ][ ] array for the form variables such as: - $data = addslashes(fread(fopen($_FILES[form_data], r), filesize($_FILES[form_data]))); and VALUES ('$_FILES[form_data][form_description]','$_FILES[form_data][data]','$_FILES[ form_data][form_data_name]','$_FILES[form_data][form_data_size]','$_FILES[fo rm_data][form_data_type]')); - The file does not get uploaded. Any assiatnce will be greatly appreciated. Thank you. TR -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] binary data in php
Greets, Register globals are to off - however the files will not upload. At wit's end - help please! Thank all in advance. TR ? if ($submit) { // connect to the database // (you may have to adjust the hostname,username or password) MYSQL_CONNECT(localhost,root,mypass); mysql_select_db(mydb); $uploadfile = $_FILES['form_data']['tmp_name']; $uploadname = $_FILES['form_data']['name']; $uploadtype = $_FILES['form_data']['type']; $uploaddesc = $_POST['desc']; // Open file for binary reading ('rb') $tempfile = fopen($uploadfile,'rb'); // Read the entire file into memory using PHP's // filesize function to get the file size. $filedata = fread($tempfile,filesize($uploadfile)); // Prepare for database insert by adding backslashes // before special characters. $filedata = addslashes($filedata); // Create the SQL query. $sql = INSERT INTO binary_data SET filename = '$uploadname', filetype = '$uploadtype', description = '$uploaddesc', bin_data = '$filedata'; $id= mysql_insert_id(); print pThis file has the following Database ID: b$id/b; echo br; echo a href=\getdata.php?id=$id\Click to view file/a; MYSQL_CLOSE(); } else { // else show the form to submit new data: ? form method=post action=?php echo $PHP_SELF; ? enctype=multipart/form-data pFile Description:br input type=text name=desc size=40 INPUT TYPE=hidden name=MAX_FILE_SIZE value=100 brFile to upload/store in database:br input type=file name=form_data size=40 pinput type=submit name=submit value=submit /form ?php } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] binary data in php
John W. Holmes [EMAIL PROTECTED] wrote in message: Remember... we're laughing with you, not at you. You forgot to call mysql_query() in your code. :) . Hmmm... I wish it was as simple as that. I inserted the mysql_query() below but it still doesn't upload the file nor does it throw an error. If you get a chance please take a look and advise. Again, my thanks for your help, TR ? if ($submit) { // connect to the database // (you may have to adjust the hostname,username or password) MYSQL_CONNECT(localhost,root,mypass); mysql_select_db(mydb); $uploadfile = $_FILES['form_data']['tmp_name']; $uploadname = $_FILES['form_data']['name']; $uploadtype = $_FILES['form_data']['type']; $uploaddesc = $_POST['desc']; // Open file for binary reading ('rb') $tempfile = fopen($uploadfile,'rb'); // Read the entire file into memory using PHP's // filesize function to get the file size. $filedata = fread($tempfile,filesize($uploadfile)); // Prepare for database insert by adding backslashes // before special characters. $filedata = addslashes($filedata); // Create the SQL query. $sql = INSERT INTO binary_data SET filename = '$uploadname', filetype = '$uploadtype', description = '$uploaddesc', bin_data = '$filedata'; $ok = @mysql_query($sql); if(!$ok)die('Database error storing the file:'.mysql_error()); $id= mysql_insert_id(); print pThis file has the following Database ID: b$id/b; echo br; echo a href=\getdata.php?id=$id\Click to view file/a; MYSQL_CLOSE(); } else { // else show the form to submit new data: ? form method=post action=?php echo $PHP_SELF; ? enctype=multipart/form-data pFile Description:br input type=text name=desc size=40 INPUT TYPE=hidden name=MAX_FILE_SIZE value=100 brFile to upload/store in database:br input type=file name=form_data size=40 pinput type=submit name=submit value=submit /form ?php } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] .doc file
Greets, I've been able to open a remote URL, read it and then lop off everything except the last line and break it into an array with its' tabs - /t . The data will then be inserted into a table. However, the following URL shows reservoir storage and is a .doc file. I am unable to run the same script with this URL since it is a .doc file - not a .txt file. The client has said that this is the only file that their office has and does not offer any csv or tsv .txt files. Is there anyway to acheive formatting this data using the following file? http://water.usgs.gov/orh/nrwww/odrm/storage2004.doc Thank you. TR -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: .doc file
Jason Barnett [EMAIL PROTECTED] wrote in message: Actually, why don't you just use plain text like this. Sheesh, sometimes I forget the easy answer :) .. Jason, Thanks for the reply. Since those figures change _daily_ on their site, I was hoping for a way to open the file, read it, adjust the format by lopping off the last line into an array and writing those values into a table - _without manually copying and pasting the data each day into a .txt file_. I have been able to do that with other remote URL's dynamically which were designed as .txt files using a tab separator. The php script opens and reads the file every time it is changed on their server and formats the data. However, this file is a .doc file and I'm trying to find a way to achieve the same result. Best... TR -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] htmlspecialchars()
php / mysql/ apache I tried the following using the call to htmlspecialchars() not sure why it is insn't working. I get the output: a href='test'Test/a Thank you. TR .. //script ? $new = htmlspecialchars(a href='test'Test/a, ENT_QUOTES); echo $new; ? // this is what is output:a href='test'Test/a // instead of this... // lt;a href=#039;test#039;gt;Testlt;/agt; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] isset() question
The following script is from Kevin Yank's book (Sitepoint). When I test it _without_ entering a name in the text box and hit submit, the _next_ page loads - however the same page should load beacuse of the conditional if (!isset($name) ): . If I replace !isset() with empty() like if (empty($name)): and do not enter a name then the _same_ page loads which is what is supposed to happen. Why doesn't the call to !isset() with the negation mark loads the next page when a name is not entered? The script predates globals being turned off and it is below. Thank you. TR . html head title Sample Page /title /head body ?php if (!isset($name) ): ? !-- No name has been provided, so we prompt the user for one. -- form action=?=$PHP_SELF? method=get Please enter your name: input type=text name=name / input type=submit value=GO / /form ?php else: ? pYour name: ?=$name?/p pThis paragraph contains a a href=newpage.php?name=?=urlencode($name)?link/a that passes the name variable on to the next document./p ?php endif; ? /body /html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] isset() question
- Original Message - From: Richard Davey [EMAIL PROTECTED] Hello Anthony, I feel the book you're learning from might not be the best out there! Especially as it uses the horrible if : else : endif notation, includes code on the same line as the PHP tags themselves and is teaching you to code with register globals on. Is the book still on sale? (i.e. did you buy it recently) or was it something you've had for a while/got 2nd hand? Best regards, Richard Davey http://www.phpcommunity.org/wiki/296.html Thank you for the reply Richard. Yes. The book is on sale at: www.sitepoint.com also, at amazon, b and n, etc. In fact, it's now in it's second edition by Kevin Yank. It's not a bad book - quite readable to a newbie like myself - but when I ran that code it didn't jive with that function call. To make sure, I downloaded it from their site and ran it again - and the same thing happened. Thank you for your help. TR --- [This E-mail scanned for viruses by gonefishingguideservice.com] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] limit run time of a function?
I have a function in my application that does a large query on my database. In certain instances the query will take to long to return and will reach the max execution time set in PHP.ini. This is ok though, it's already set to 90 secs and I don't want it any longer than that. What I would like is to have a way that I can time a function. If the function takes to long to return data, kill it and follow some other path in my app to let the user know what's going on. What I'm trying to avoid is the warning from PHP saying that the script reached max execution time. The user gets all confused and then I get help desk calls. There has got to be another way. Any ideas? - Anthony -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: odbc functions - not binary safe?
If you're connecting to the mySQL database through ODBC (why not just connect directly to mySQL server?) ... then you probably have to escape with a single quote. For most ODBC drivers you escape ' with '' (two single quotes) . took me a while to figure that one out, but works for me. :) - Anthony C C [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi, I'm trying to insert binary data into a MS SQL Server database. Text files are added fine, but binary files with null bytes are not. The field I'm adding the binary data to is image type. I get an error about unclosed quotation marks at the null byte, but I've replaced ' with ''. I tried escaping the null byte with a backslach, but it just changes it to the string \0 when I download it. Anyone have any ideas about this? __ Do you Yahoo!? Yahoo! SiteBuilder - Free web site building tool. Try it! http://webhosting.yahoo.com/ps/sb/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php_hostconnect()
I currently have websites with two ISP's. I am getting a lot of warnings throughout a .php script on one server - such as: php_hostconnect() I have used the _same_ .php script exactly on my other ISP's server and I don't get any warnings. In addition, I have tested this script locally on Apache server without any errors. The site where I do not get warnnings has php 4.1.1 installed - wheras the other site where I get php_hostcoonect() warnings is php 4.2.3 Any help will be greatly appreciated. Thank you. Tony Ritter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] localhost mail
Using php/apache/mysql on win 98 I am testing an mail script. The script has a .html form which receives the text input and then a .php script to execute the variables in a mail() function. When I publish both files - the .html and .php - to my ISP's server and enter the data and hit submit I receive an e-mail. In my php.ini file I have configured the SMTP to the name of the ISP's email server. However, when testing the same script out locally on Apache Server: I get the form box, enter the data but I do not receive an email. I only use one ISP. Is it possble they have two name servers and that is why I am not receiving an e-mail when testing on Apache Server? Thank you for any help. Best... Tony Ritter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] mail()
Using php/apache/mysql I am testing an mail script. The script has a .html form which receives the text input and then a .php script to execute the variables in a mail() function. When I publish both files - the .html and .php - to my ISP's server and enter the data and hit submit I receive an e-mail. In my php.ini file I have configured the SMTP to the name of the ISP's email server. However, when testing the same script out locally on Apache Server: I get the form box, enter the data but I do not receive an email. I only use one ISP. Is it possble they have two name servers and that is why I am not receiving an e-mail when testing on Apache Server? Thank you for any help. Best... Tony Ritter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] session / garbage collection problem
PHP Version 4.2.2 Apache 2 RH 9 The problem is that session files in the /tmp directory are completely cleared out at random intervals of time. We assume that the randomness is due to our session.gc_probability setting of 1 causing it to run for 1% of new sessions. What we don't understand is why the garbage collector is removing valid sessions. session.gc_maxlifetime is set to 86400 (24 hours) so it should keep them around for a good long time. However, it seems that ALL session files are deleted when the garbage collector runs. In some cases session files were deleted for sessions that had been around for less than a minute. We've thought of several hacks that would control the problem but we can't come up with any way to fix it. Thanks in advance, Anthony -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] session / garbage collection problem
Redhat 9 kernel 2.4.20-18.9bigmem ext3 fs Marek Kilimajer [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] What filesystem and OS is this? Anthony Kaufman wrote: PHP Version 4.2.2 Apache 2 RH 9 The problem is that session files in the /tmp directory are completely cleared out at random intervals of time. We assume that the randomness is due to our session.gc_probability setting of 1 causing it to run for 1% of new sessions. What we don't understand is why the garbage collector is removing valid sessions. session.gc_maxlifetime is set to 86400 (24 hours) so it should keep them around for a good long time. However, it seems that ALL session files are deleted when the garbage collector runs. In some cases session files were deleted for sessions that had been around for less than a minute. We've thought of several hacks that would control the problem but we can't come up with any way to fix it. Thanks in advance, Anthony -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] session / garbage collection problem
Well, we host our own so what I was thinking wouldn't quite work for your situation. However, I've seen a method that I think would work pretty well for you. Basically, you store all the data you want to be persistant between requests in a database. You could use the session id you get from the browser as the key for a sessions table. So, getting session data looks something like this: $sess_id = session_id(); $result = SELECT * FROM sessions WHERE session_id = '$sess_id' Since session_id() gets it's information from the HTTP request, and the browser keeps the session cookie (at least it does in our case), you don't rely on the stuff in the tmp directory at all. You could also emulate PHP's session-in-file approach using a similar method. Tony Crockford [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On Fri, 19 Dec 2003 13:37:06 -0800, Anthony Kaufman wrote: PHP Version 4.2.2 Apache 2 RH 9 The problem is that session files in the /tmp directory are completely cleared out at random intervals of time. We assume that the randomness is due to our session.gc_probability setting of 1 causing it to run for 1% of new sessions. What we don't understand is why the garbage collector is removing valid sessions. session.gc_maxlifetime is set to 86400 (24 hours) so it should keep them around for a good long time. However, it seems that ALL session files are deleted when the garbage collector runs. In some cases session files were deleted for sessions that had been around for less than a minute. We've thought of several hacks that would control the problem but we can't come up with any way to fix it. I'd be interested to hear of the hacks.. I've got a hosted application that has started losing session state since they upgraded PHP and they're blaming me and I know it isn't because I have the same spec locally and the same script on different servers. is there something I can add to my script or in an htaccess file to keep my sessions away from their garbage collection, as it seems likely that I have a similar situation to you. TIA Tony -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Where'd my session go??
I've got an issue with an app I wrote. I store some information about the user and if they are logged into the app in session variables. The problem is that if they leave the app idle for a while ( about an hour) the session information is lost, so the user is prompted to log back into the application. I checked session.cookie_lifetime and it's set to 0. The client side is IE 5.5 or 6. What could be causing the session to be lost? Thanks for your help :) - Anthony -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] count()
Marek Kilimajer [EMAIL PROTECTED] wrote in message: There are 10 '[PAGEBREAK]' substrings in the string. If the string is split apart at these substrings, it will give you total 11 parts. Thank you. TR -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] count()
Greetings- I'm have the follwing string called $text and throughout this string I'd like to split this into an array by calling spliti() at the tag called PAGEBREAK. So, I count the array elements starting at 0 and get to 9. When I call count(), I get 11. Could somebody please explain why this is? Thank you. TR . ? $text= aaa[PAGEBREAK] //this is the 0 element bbb[PAGEBREAK] //[1] ccc[PAGEBREAK] //[2] ddd[PAGEBREAK] //[3] eee[PAGEBREAK] //[4] fff[PAGEBREAK] //[5] ggg[PAGEBREAK] //[6] hhh[PAGEBREAK] //[7] iii[PAGEBREAK] //[8] jjj[PAGEBREAK] //...and this is the 9th element ; $regexp=\[PAGEBREAK]; $textarray=spliti($regexp,$text); $num_array=count($textarray); $another_num_array=count($textarray)-1; echo There are .$num_array. elements using the count() function.br; echo If I subtract 1 since elements begin at 0, there are .$another_num_array..; //This is the output using count(): //... //There are 11 elements using the count() function. //If I subtract 1 since elements begin at 0, there are 10 ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] $_SESSION var sometimes set, sometimes not
Hi, The following code sometimes produces output indicating that the session variables have been set, and sometimes is says that they have not been set. Unfortunately the server is not mine to configure, but if there is a problem with it, I can get in touch with the right people. Is the script properly written? Is it a server problem? html head titleTest stuff.../title /head body ?php session_start(); // enable session level global variables if (isset($_POST['action']) $_POST['action'] == 'sub1' ) sub1(); else { session_unset(); // all variables start fresh here $_SESSION['test']='HERE I AM!br'; echo $_SESSION['test']; print_r ($_SESSION); } function sub1() { echo sub1 routinebr; print_r ($_SESSION); if ( isset($_SESSION['test']) ) echo $_SESSION['test']; else echo 'variable not setbr'; } /// ? form action=?php echo $_SERVER['PHP_SELF']; ? method=POST select name=sub1 option sub1 /optionbr /select input type=hidden name=action value=sub1 input type=submit name=submit value=go /form /body /html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $_SESSION var sometimes set, sometimes not
I just tried that. It made no change. Still sometimes works, sometimes doesn't. It's on the order of clicks. It may work three times in a row, then fail a couple times. It's very strange. John W. Holmes [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Anthony Whipple wrote: The following code sometimes produces output indicating that the session variables have been set, and sometimes is says that they have not been set. Unfortunately the server is not mine to configure, but if there is a problem with it, I can get in touch with the right people. Is the script properly written? Is it a server problem? html head titleTest stuff.../title /head body ?php session_start(); // enable session level global variables This shouldn't work at all. You need to have session_start() before any HTML or output. The beginning of your file should be ?php session_start(); ? html ... -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] file paths and binaries
Greetings all, I'm looking for a tutorial or some assistance in explaning how store and then open and read a binary file using php/mysql. I've got a few tutorials about storing the binary data _within_ a mysql table from Kevin Yank, phpbuilder, etc. but I've heard that it's sometime better to keep your binaries on the server and not in the database. Thus, if the developer just keeps the file path in a VARCHAR column like: C:\apache\images\house.jpg C:\apache\images\tree.jpg etc... and then directs that file be fopen() fread(), etc. it will work without the added overhead. I'm a bit lost in what happens after the filepaths are inserted into the database and what steps follow in the script so that they can be opened and read. Any help, URL's or tutorials will be of assistance. Thank you. TR -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] download from mysql script
I'm trying to receive data from a mysql database through php. Using the command line at mysql listed below gives me a result set. I am able to connect to the database through php, however, when using the following script, I receive no data when the data is in the table called pictures in the db called sitename. ? if($ID) { @MYSQL_CONNECT(localhost,root,thepassword); @mysql_select_db(sitename); $query = select bin_data,filetype from pictures where ID=$ID; $result = @MYSQL_QUERY($query); $data = @MYSQL_RESULT($result,0,bin_data); $type = @MYSQL_RESULT($result,0,filetype); Header( Content-type: $type); echo $data; } ? // In browser window it reads: // http://localhost/download.php?filename=7 //...and on the Command Line using the following query: // SELECT filetype FROM pictures where ID=$ID // gives me a image/pjpeg as the result set. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] =sessions / J. Meloni Textbook=
Thanks again but here's what happens when I run that. The form box appears. I select an option. I hit submit. The page that loads says: Warning: Invalid argument supplied for foreach() in c:\apache\htdocs\session_yyy.php on line 13 I then hit the link: Back to content page. The form box appears. I select _another_ option. I hit submit. The page that loads now has the _second_ value I have submitted but not the first. Like: 1. 2. Hal 2000 Is there a way to get the first option into the array? If you get a chance please try the code. Thanking you for your time. TR .. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] =sessions / J. Meloni Textbook=
Sure. Here it is. There are three scripts. session_1.php: the original form script. session_1a.php: a revised script with a conditional else. session_2.php: the receiving script for the session array variable. Running script 1a and 2 works fine. However the original script 1 and 2 gives me a error when returning to the contents page the first time - it then fills the contents starting with the number 2 on subsequent page loads. as in: 1. 2. Hal 2000 3. Sonic Screwdriver Try it and see and let me know. Thank you. TR . // this is the original script // script session_1.php ?php session_start(); ? html head titleStoring an array with a session/title /head body h1Product Choice Page/h1 ?php if (isset($_POST[form_products])) { if (!empty($_SESSION[products])) { $products = array_unique( array_merge(unserialize($_SESSION[products]), $_POST[form_products])); } $_SESSION[products] = serialize($products); print pYour products have been registered!/p; } ? form method=POST action=?php $_SERVER[PHP_SELF] ? PSelect some products:br select name=form_products[] multiple size=3 optionSonic Screwdriver/option optionHal 2000/option optionTardis/option optionORAC/option optionTransporter bracelet/option /select brbr input type=submit value=choose /form brbr a href=session_2.phpcontent page/a /body /html ... //this is a revised script with a conditional else //script session_1a.php ?php session_start(); ? html head titleStoring an array with a session/title /head body h1Product Choice Page/h1 ?php if (isset($_POST['form_products'])) { if (!empty($_SESSION['products'])) { $products = array_unique( array_merge(unserialize($_SESSION['products']), $_POST['form_products'])); }else{ //this conditional has been added $products = $_POST['form_products'] ; } $_SESSION['products'] = serialize($products); print pYour products have been registered!/p; } ? form method=POST action=?php $_SERVER[PHP_SELF] ? PSelect some products:br select name=form_products[] multiple size=3 optionSonic Screwdriver/option optionHal 2000/option optionTardis/option optionORAC/option optionTransporter bracelet/option /select brbr input type=submit value=choose /form brbr a href=session_2.phpcontent page/a /body /html .. //this is session_2.php ?php session_start(); ? html head titleListing 16.5 Accessing session variables/title /head body h1 Content Page/h1 ?php if (isset($_SESSION[products])) { print bYour cart:/bol\n; foreach (unserialize($_SESSION[products]) as $p) { print li$p; } print /ol; } ? a href=session_1.phpBack to product choice page/a /body /html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] =sessions / J. Meloni Textbook=
Additinally, upon looking at the session files in: C:/apache/tmp: I get from session file from script session_1a.php: products|s:23:a:1:{i:0;s:6:Tardis;}; ... However, looking at session file from script session_1.php: I get: products|s:2:N;; -- Anthony Ritter [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Sure. Here it is. There are three scripts. session_1.php: the original form script. session_1a.php: a revised script with a conditional else. session_2.php: the receiving script for the session array variable. Running script 1a and 2 works fine. However the original script 1 and 2 gives me a error when returning to the contents page the first time - it then fills the contents starting with the number 2 on subsequent page loads. as in: 1. 2. Hal 2000 3. Sonic Screwdriver Try it and see and let me know. Thank you. TR . // this is the original script // script session_1.php ?php session_start(); ? html head titleStoring an array with a session/title /head body h1Product Choice Page/h1 ?php if (isset($_POST[form_products])) { if (!empty($_SESSION[products])) { $products = array_unique( array_merge(unserialize($_SESSION[products]), $_POST[form_products])); } $_SESSION[products] = serialize($products); print pYour products have been registered!/p; } ? form method=POST action=?php $_SERVER[PHP_SELF] ? PSelect some products:br select name=form_products[] multiple size=3 optionSonic Screwdriver/option optionHal 2000/option optionTardis/option optionORAC/option optionTransporter bracelet/option /select brbr input type=submit value=choose /form brbr a href=session_2.phpcontent page/a /body /html ... //this is a revised script with a conditional else //script session_1a.php ?php session_start(); ? html head titleStoring an array with a session/title /head body h1Product Choice Page/h1 ?php if (isset($_POST['form_products'])) { if (!empty($_SESSION['products'])) { $products = array_unique( array_merge(unserialize($_SESSION['products']), $_POST['form_products'])); }else{ //this conditional has been added $products = $_POST['form_products'] ; } $_SESSION['products'] = serialize($products); print pYour products have been registered!/p; } ? form method=POST action=?php $_SERVER[PHP_SELF] ? PSelect some products:br select name=form_products[] multiple size=3 optionSonic Screwdriver/option optionHal 2000/option optionTardis/option optionORAC/option optionTransporter bracelet/option /select brbr input type=submit value=choose /form brbr a href=session_2.phpcontent page/a /body /html .. //this is session_2.php ?php session_start(); ? html head titleListing 16.5 Accessing session variables/title /head body h1 Content Page/h1 ?php if (isset($_SESSION[products])) { print bYour cart:/bol\n; foreach (unserialize($_SESSION[products]) as $p) { print li$p; } print /ol; } ? a href=session_1.phpBack to product choice page/a /body /html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] =sessions / J. Meloni Textbook=
Using mysql, apache and win98 The following code is from PHP, mySQL and Apache (SAMS) by Julie Meloni. Page 338-339 (hour 16). After choosing my selections in the form box and hitting submit I get: ... Warning: Invalid argument supplied for foreach() in c:\apache\htdocs\listing16.5.php on line 13 .. I checked her errata at thickbooks.com but there was nothing for this chapter. Any help will be greatly appreciated. Thank you. TR --- // script 16.4.php ?php session_start(); ? html head titleListing 16.4 Storing an array with a session/title /head body h1Product Choice Page/h1 ?php if (isset($_POST[form_products])) { if (!empty($_SESSION[products])) { $products = array_unique( array_merge(unserialize($_SESSION[products]), $_POST[form_products])); } $_SESSION[products] = serialize($products); print pYour products have been registered!/p; } ? form method=POST action=?php $_SERVER[PHP_SELF] ? PSelect some products:br select name=form_products[] multiple size=3 optionSonic Screwdriver/option optionHal 2000/option optionTardis/option optionORAC/option optionTransporter bracelet/option /select brbr input type=submit value=choose /form brbr a href=listing16.5.phpcontent page/a /body /html .. // script 16.5.php html head titleListing 16.5 Accessing session variables/title /head body h1 Content Page/h1 ?php if (isset($_SESSION[products])) { print bYour cart:/bol\n; foreach (unserialize($_SESSION[products]) as $p) { print li$p; } print /ol; } ? a href=listing16.4.phpBack to product choice page/a /body /html ... Warning: Invalid argument supplied for foreach() in c:\apache\htdocs\listing16.5.php on line 13 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] =sessions / J. Meloni Textbook=
Thanks John and others. I'm using the script and no values show up in the page: session_bb.php after I submit the values in the select form. If somebody would like to test both scripts (session_aa.php and session_bb.php) and get back to me I would be grateful. As I said, these were from her book/CD. Thank you. TR . // this is session_aa.php script ?php session_start(); ? html head titleListing 16.4 Storing an array with a session/title /head body h1Product Choice Page/h1 ?php if (isset($_POST[form_products])) { if (!empty($_SESSION[products])) { $products = array_unique( array_merge($_SESSION[products], $_POST[form_products])); } $_SESSION[products] = $products; print pYour products have been registered!/p; } ? form method=POST action=?php $_SERVER[PHP_SELF] ? PSelect some products:br select name=form_products[] multiple size=3 optionSonic Screwdriver/option optionHal 2000/option optionTardis/option optionORAC/option optionTransporter bracelet/option /select brbr input type=submit value=choose /form brbr a href=session_bb.phpcontent page/a /body /html .. // ...and this is session_bb.php script ? session_start(); ? html head titleListing 16.5 Accessing session variables/title /head body h1 Content Page/h1 ?php if (isset($_SESSION[products])) { print bYour cart:/bol\n; foreach (unserialize($_SESSION[products]) as $p) { print li$p; } print /ol; } ? a href=session_aa.phpBack to product choice page/a /body /html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] naughty words / filter
Hi, I'm trying to filter a word - in this case - called badword1 - to be replaced with asterisks. Listed below is my .html form and .php receiving script. I've also added the same script which gets a hardcoded string. In the first example, the output still shows the original message _without_ replacing the badword whereas in the second example with the hardcoded string - it is getting replaced with *. Any assistance would be greatly appreciated. Thank you. Tony Ritter html form action=themessage.php method=post p Your message:br textarea name=message cols=40 rows=5 /textareabr input type =submit name=submit value=Submit /form /html // example #1: in the script the text in the variable $guestbook does not get replaced. ? $dirty_words = array(badword1,badword2,badword3); $guestbook = stripslashes($message); foreach ($dirty_words as $word){ $message = str_replace($word, , $guestbook); } echo $message; ? . // example #2: in this snippet, the hardcoded string $guestbook gets replaced with ? $guestbook=Boy, that Tony - he is a real badword1. $dirty_words = array(badword1,badword2,badword3); $message = $guestbook; foreach ($dirty_words as $word){ $message = str_replace($word, , $message); } echo $message; ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: naughty words / filter
Was able to get this to filter: . ? } $guestbook = stripslashes($message); $this_is_the_message=$guestbook; $dirty_words = array(badword1,badword2,badword3); $message = $this_is_the_message; foreach ($dirty_words as $word){ $message = str_replace($word, , $message); } echo $message; ? TR -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] mysql output
The following code snippet outputs a table from a mySQL database. In version 1, I am able to get alternating background cell colors. However, the output gives me the same post five times. In version 2, I am able to receive five separate posts - which is what I'm looking for - but I'd like to get alternating cell backgrounds. Somewhere my syntax is failing me. Any advice would be greatly appreciated. Thank you. Tony Ritter // version 1: ?php //check for required info from the query string if (!$_GET[topic_id]) { header(Location: topiclist.php); exit; } //connect to server and select database $conn = mysql_connect(localhost, root, thisisapassword) or die(mysql_error()); mysql_select_db(sitename,$conn) or die(mysql_error()); //verify the topic exists $verify_topic = select topic_title from forum_topics where topic_id = $_GET[topic_id]; $verify_topic_res = mysql_query($verify_topic, $conn) or die(mysql_error()); if (mysql_num_rows($verify_topic_res) 1) { //this topic does not exist $display_block = PemYou have selected an invalid topic. Please a href=\topiclist.php\try again/a./em/p; } else { //get the topic title $topic_title = stripslashes(mysql_result($verify_topic_res,0, 'topic_title')); //gather the posts $get_posts = select post_id, post_text, date_format(post_create_time, '%b %e %Y at %r') as fmt_post_create_time, post_owner from forum_posts where topic_id = $_GET[topic_id] order by post_create_time asc; $get_posts_res = mysql_query($get_posts,$conn) or die(mysql_error()); //create the display string $display_block = PShowing posts for the strong$topic_title/strong topic:/p table width=100% cellpadding=3 cellspacing=1 border=1 tr th bgcolor=\#497fbf\font color=\#ff\AUTHOR/font /th th bgcolor=\#497fbf\font color=\#ff\POST/font/th /tr; while ($posts_info = mysql_fetch_array($get_posts_res)) { $post_id = $posts_info['post_id']; $post_text = nl2br(stripslashes($posts_info['post_text'])); $post_create_time = $posts_info['fmt_post_create_time']; $post_owner = stripslashes($posts_info['post_owner']); $i = 0; while ($posts_info = @mysql_fetch_array($get_posts_res)) {// begin light-dark loop $row_class = (($i % 2) == 0) ? 'light' : 'dark'; $display_block .= tr td width=35% valign=top class=\$row_class\p$post_ownerbr[$post_create_time]/td td width=65% valign=top class=\$row_class\p$post_textbrbr a href=\replytopost.php?post_id=$post_id\img src=\submit.gif\ border=\0\/a/td /tr; $i++; } } //close up the table $display_block .= /table; } ? html head style p {font-family:sans arial; font-size: 1.25em; } th { font-family:arial; font-size: .75em;\ font-color:#ff; } td {border:1px solid #ff; font-family:arial; font-size:.5em; color: #2d73b9} .light { color:#000; background-color:#eee; } .dark { color:#000; background-color:#aaa; } /style /head body titlePosts in Topic/title /head body h1Posts in Topic/h1 ?php print $display_block; ? /body /html . // version 2: ?php //check for required info from the query string if (!$_GET[topic_id]) { header(Location: topiclist.php); exit; } //connect to server and select database $conn = mysql_connect(localhost, root, thisisapassword) or die(mysql_error()); mysql_select_db(sitename,$conn) or die(mysql_error()); //verify the topic exists $verify_topic = select topic_title from forum_topics where topic_id = $_GET[topic_id]; $verify_topic_res = mysql_query($verify_topic, $conn) or die(mysql_error()); if (mysql_num_rows($verify_topic_res) 1) { //this topic does not exist $display_block = PemYou have selected an invalid topic. Please a href=\topiclist.php\try again/a./em/p; } else { //get the topic title $topic_title = stripslashes(mysql_result($verify_topic_res,0, 'topic_title')); //gather the posts $get_posts = select post_id, post_text, date_format(post_create_time, '%b %e %Y at %r') as fmt_post_create_time, post_owner from forum_posts where topic_id = $_GET[topic_id] order by post_create_time asc; $get_posts_res = mysql_query($get_posts,$conn) or die(mysql_error()); //create the display string $display_block = PShowing posts for the strong$topic_title/strong topic:/p table width=100% cellpadding=3 cellspacing=1 border=1 tr th bgcolor=\#497fbf\font color=\#ff\AUTHOR/font /th th bgcolor=\#497fbf\font color=\#ff\POST/font/th /tr; while ($posts_info = mysql_fetch_array($get_posts_res)) { $post_id = $posts_info['post_id']; $post_text = nl2br(stripslashes($posts_info['post_text'])); $post_create_time = $posts_info['fmt_post_create_time']; $post_owner = stripslashes($posts_info['post_owner']); //add to display $display_block .= tr td width=35% valign=topp$post_ownerbr[$post_create_time]/td
Re: [PHP] mysql output
You also asked a very, very common question, i.e. how to alternate colors in table rows... there are a ton of websites/tutorials out there that explain ways to do this. ---John Holmes... Apologies for the lengthy code. I've tried using a few tutorials and am still adrift. Here's a snippet: Thank you for any assistance. Tony Ritter .. ? table width=100% cellpadding=3 cellspacing=1 border=1 tr th bgcolor=\#497fbf\font color=\#ff\AUTHOR/font /th th bgcolor=\#497fbf\font color=\#ff\POST/font/th /tr; while ($posts_info = mysql_fetch_array($get_posts_res)) { $post_id = $posts_info['post_id']; $post_text = nl2br(stripslashes($posts_info['post_text'])); $post_create_time = $posts_info['fmt_post_create_time']; $post_owner = stripslashes($posts_info['post_owner']); $color1 = #CCFFCC; $color2 = #BFD8BC; $posts_info = 0; $row_color = ($posts_info % 2) ? $color1 : $color2; //add to display $display_block .= tr td width=35% valign=top bgcolor=\$row_color\p$post_ownerbr[$post_create_time]/td td width=65% valign=top bgcolor=\$row_color\p$post_textbrbr a href=\replytopost.php?post_id=$post_id\strongREPLY TO POST/strong/a/td /tr; } //close up the table $display_block .= /table; ? . -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql output
Thanks very much John. I found the following and inserted it into my snippet for alternating backgoriund colors. However, I'm not sure I understand the logic. This part: ... $alternate = 2; while ($posts_info = mysql_fetch_array($get_posts_res)) { $post_id = $posts_info['post_id']; $post_text = nl2br(stripslashes($posts_info['post_text'])); $post_create_time = $posts_info['fmt_post_create_time']; $post_owner = stripslashes($posts_info['post_owner']); if ($alternate == 1) { $color = #eaf3da; $alternate = 2; } else { $color = #d5eae9; $alternate = 1; } Best... Tony . $display_block = PShowing posts for the strong$topic_title/strong topic:/p table width=100% cellpadding=3 cellspacing=1 border=0 tr th bgcolor=\#497fbf\font color=\#ff\AUTHOR/font /th th bgcolor=\#497fbf\font color=\#ff\POST/font/th /tr; $alternate = 2; while ($posts_info = mysql_fetch_array($get_posts_res)) { $post_id = $posts_info['post_id']; $post_text = nl2br(stripslashes($posts_info['post_text'])); $post_create_time = $posts_info['fmt_post_create_time']; $post_owner = stripslashes($posts_info['post_owner']); if ($alternate == 1) { $color = #eaf3da; $alternate = 2; } else { $color = #d5eae9; $alternate = 1; } //add to display $display_block .= tr td width=35% valign=top bgcolor=\$color\pa href=mailto:$post_owner$post_ownerbr/a[$post_create_time]/td td width=65% valign=top bgcolor=\$color\p$post_textbrbr a href=\replytopost.php?post_id=$post_id\img src=\reply.gif\ border=\0\ align=\right\/a/td /tr; } //close up the table $display_block .= /table; - Original Message - From: John W. Holmes [EMAIL PROTECTED] To: Anthony Ritter [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Tuesday, August 19, 2003 9:59 PM Subject: Re: [PHP] mysql output Anthony Ritter wrote: You also asked a very, very common question, i.e. how to alternate colors in table rows... there are a ton of websites/tutorials out there that explain ways to do this. ---John Holmes... Apologies for the lengthy code. I've tried using a few tutorials and am still adrift. Here's a snippet: Thank you for any assistance. Tony Ritter .. ? table width=100% cellpadding=3 cellspacing=1 border=1 tr th bgcolor=\#497fbf\font color=\#ff\AUTHOR/font /th th bgcolor=\#497fbf\font color=\#ff\POST/font/th /tr; while ($posts_info = mysql_fetch_array($get_posts_res)) { $post_id = $posts_info['post_id']; $post_text = nl2br(stripslashes($posts_info['post_text'])); $post_create_time = $posts_info['fmt_post_create_time']; $post_owner = stripslashes($posts_info['post_owner']); $color1 = #CCFFCC; $color2 = #BFD8BC; $posts_info = 0; Move the above line outside of your while loop $row_color = ($posts_info % 2) ? $color1 : $color2; $row_color = ($posts_info++ % 2) ? $color1 : $color2; You were setting $posts_info to zero in each loop, so it's never going to change. You must set it to zero outside of the loop, then increment it within. You could make this real easy and just do: $row_color = ($row_color == $color1) ? $color2 : $color1; -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ PHP|Architect: A magazine for PHP Professionals www.phparch.com --- [This E-mail scanned for viruses by gonefishingguideservice.com] --- [This E-mail scanned for viruses by gonefishingguideservice.com] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] discussion forum from j. meloni's book
Ford, Mike [LSS] [EMAIL PROTECTED] writes: You have a conceptual misconception. In effect, you need to read that query as: select ft.topic_id, ft.topic_title from ( forum_posts as fp left join forum_topics as ft on fp.topic_id = ft.topic_id ) where fp.post_id = $_GET[post_id] In other words, the left join of the two tables is treated as a single virtual table, from which you could select any column of either original table. .. Thanks Mike for the clear explanation. TR -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Repopulating forms
becasue your $test string contains double quotes. This is casuing you to end the value element in the input tag. - Anthony Gerard L Petersen [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi My code looks like this. ?PHP $test = gerard's name is \gerard\; echo $test.br; echo 'input type=text name=test2 value='.$test.'br'; ? form action=test2.php method=post input type=text name=foo value= / input type=submit name=sub value=submit /form When i run it the bit after the quotes are truncated. Where it truncates depends on what type of quote i am using. Any ideas? Thanks Gerard -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] email confirmation script
Thanks Jackson. I appreciate the assistance. Am I on the right track? Best... TR .. // this is the form html body form action=post method=process.php p Your e-mail address:br input type=text name=namebr input type=text name=emailbr input type=submit name=submit value=submit /body /form /html ... //process.php ? if ($email) { $secret_variable = something_only_you_know; $confirmationID = md5($email.$secret_variable); $body = Thank you for registering $name \n;; $body .= Please click on the a href=mailto:[EMAIL PROTECTED]/email_verify.php?email=$emailc onfirmation_ID=$confirmation_IDlink/a mail($_POST['email'],'Thank you',$body,'From: Us Fish'); } ... //email_verify.php ? if ($_GET['confirmationID'] = md5($_GET['email'].$secret_variable)) { // insert the user into the database } else { // display an error message } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] discussion forum from j. meloni's book
The following code is From Julie Meloni's textbook - PHP, mySQL and Apache (SAMS) on page 305-307 / Listing 14.5: It's the last script of a discussion forum which is comprised of four php files and one html file. The script can be seen at: http://www.thickbook.com Chapter 14 off the zipfile. Anyway, in the textbook and the zip her mySQL query reads: ... $verify = select ft.topic_id, ft.topic_title from forum_posts as fp left join forum_topics as ft on fp.topic_id = ft.topic_id where fp.post_id = $_GET[post_id]; . The part that I'm confused about is: ... select ft.topic_id, ft.topic_title from forum_posts It seem that the alias of ft refers to forum_title - not forum_posts. In fact, I switched the query to read as follows: $verify = select ft.topic_id, ft.topic_title from forum_topics as ft left join forum_posts as fp on fp.topic_id = ft.topic_id where fp.post_id = $_GET[post_id]; .. And that seems to run fine. Any explanations will be appreciated. Her original code is below. Thank you. Tony Ritter .. ?php //connect to server and select database; we'll need it soon $conn = mysql_connect(localhost, root, thisisapassword) or die(mysql_error()); mysql_select_db(sitename,$conn) or die(mysql_error()); //check to see if we're showing the form or adding the post if ($_POST[op] != addpost) { // showing the form; check for required item in query string if (!$_GET[post_id]) { header(Location: topiclist.php); exit; } //still have to verify topic and post $verify = select ft.topic_id, ft.topic_title from forum_topics as ft left join forum_posts as fp on fp.topic_id = ft.topic_id where fp.post_id = $_GET[post_id]; $verify_res = mysql_query($verify, $conn) or die(mysql_error()); if (mysql_num_rows($verify_res) 1) { //this post or topic does not exist header(Location: topiclist.php); exit; } else { //get the topic id and title $topic_id = mysql_result($verify_res,0,'topic_id'); $topic_title = stripslashes(mysql_result($verify_res, 0,'topic_title')); print html head titlePost Your Reply in $topic_title/title /head body h1Post Your Reply in $topic_title/h1 form method=post action=\$_SERVER[PHP_SELF]\ pstrongYour E-Mail Address:/strongbr input type=\text\ name=\post_owner\ size=40 maxlength=150 PstrongPost Text:/strongbr textarea name=\post_text\ rows=8 cols=40 wrap=virtual/textarea input type=\hidden\ name=\op\ value=\addpost\ input type=\hidden\ name=\topic_id\ value=\$topic_id\ Pinput type=\submit\ name=\submit\ value=\Add Post\/p /form /body /html; } } else if ($_POST[op] == addpost) { //check for required items from form if ((!$_POST[topic_id]) || (!$_POST[post_text]) || (!$_POST[post_owner])) { header(Location: topiclist.php); exit; } //add the post $add_post = insert into forum_posts values ('', '$_POST[topic_id]', '$_POST[post_text]', now(), '$_POST[post_owner]'); mysql_query($add_post,$conn) or die(mysql_error()); //redirect user to topic header(Location: showtopic.php?topic_id=$topic_id); exit; } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Help Please in using fopen in PHP
[EMAIL PROTECTED] wrote in message: Hi Folks, I am currently learning php and Mysql a scripting language and DB i just feel in love with. I am currently having problem in opening file to put data collected from clients when the purchase from an online shop. The scripts is as follows. where i am having problem is this // open file for appending $fp = fopen($DOCUMENT_ROOT/../orders/orders.txt , 'a'); [snipped] . Looks like that script was pulled from Welling and Thomson's textbook on PHP and mySQL. I've got the first edition - SAMS. You need to create a file called: orders.txt which which would reside in the path of your argument to fopen(). Best... Tony Ritter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PDF Thumbnail with PHP?
Does anyone know if there is a way to generate a thumbnail of the 1st page of a PDF document using PHP. I have an application that archives PDF files, beeing able to generate small preview images of the documents would be really cool :) - Anthony -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PDF Thumbnail with PHP?
Unfortunatly, that's not what I'm trying to do. That function will add an image to a PDF file as a thumbnail. What I want to do, is read a PDF file, and generate a thumbnail in the form of a gif or jpg and have it display in the browser. Thanks for the thought though. - Anthony Jay Blanchard [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] [snip] Does anyone know if there is a way to generate a thumbnail of the 1st page of a PDF document using PHP. I have an application that archives PDF files, beeing able to generate small preview images of the documents would be really cool :) [/snip] This may be just what you are looking for http://us3.php.net/manual/en/function.pdf-add-thumbnail.php Have a pleasant and creative day! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] discussion forum from j. meloni's book
Ford, Mike [LSS] [EMAIL PROTECTED] writes: You have a conceptual misconception. In effect, you need to read that query as: select ft.topic_id, ft.topic_title from ( forum_posts as fp left join forum_topics as ft on fp.topic_id = ft.topic_id ) where fp.post_id = $_GET[post_id] In other words, the left join of the two tables is treated as a single virtual table, from which you could select any column of either original table. .. Thanks Mike for the clear explanation. TR --- [This E-mail scanned for viruses by gonefishingguideservice.com] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] email confirmation script
Hi, I'm trying to find a script that does the following: 1. A user is presented with a form with a textbox for their e-mail address. 2. The user types in their e-mail addrees and submits the form. 3. A note is then sent from that server if their e-mail address , in fact, exists. 3. If the e-mail address does exist - the user receives a note. The user is then presented with a link which they click to confirm and their e-mail address in then inserted into the database. I've searched through google for: e-mail, confirmation, php, etc. and have not come up with anything. If anyone has code that I could look at, I would greatly appreciate it. Many thanks, Tony Ritter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] discussion forum from j. meloni's book
Jennifer Goodie [EMAIL PROTECTED] writes: You didn't switch the aliases around, you just switched the join order. This will provide unexpected results. In order to understand it, you should read up on left joins. http://www.mysql.com/doc/en/JOIN.html Thank you. But... // the query $verify = select ft.topic_id, ft.topic_title from forum_posts as fp left join forum_topics as ft on fp.topic_id = ft.topic_id where fp.post_id = $_GET[post_id]; ... My question: why - or how can - the columns ft.topic_id and ft.topic_title come from the table forum_posts? In the original schema, there is no column called topic_title in the table called forum_posts. When I change the following to read: $verify = select ft.topic_id, ft.topic_title from forum_topics as ft left join forum_posts as fp on fp.topic_id = ft.topic_id where fp.post_id = $_GET[post_id]; It works fine. /*Roughly translated: Select the column ft.topic_id along with the column ft.topic_title from the table called forum_topics which we'll call ft. Then join the table called forum_topics onto the table called forum_posts and match the records where topic_id corresponds in both tables along with post_id corresponds in both tables.*/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] discussion forum from j. meloni's book
Jennifer Goodie [EMAIL PROTECTED] writes: They don't. ft is aliased to forum_topics. That's right. ft is aliased to the forum_topics table. The query reads: ... $verify = select ft.topic_id, ft.topic_title from forum_posts as fp left join forum_topics as ft on fp.topic_id = ft.topic_id where fp.post_id = $_GET[post_id]; . The question: How can the column that is called: ft.topic_title in the select statement above be taken from the table called forum_posts when it was not there in the schema? SELECT ft.topic_id, ft.topic_title FROM forum_posts...[snipped] Thank you. TR --- [This E-mail scanned for viruses by gonefishingguideservice.com] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] email confirmation script
This is what I receive via e-mail after I click submit using the following code. As you can see - the html attribute a href= shows up and the whole string in linked. All I was looking for is a link to the URL and the word - Click - to be underlined showing the link. Additionally, the value (as in key/value) part of confirmation_ID is nowhere to be found in the query string. Thank you for any assistance. Tony Ritter . // This is what I get back via e-mail: - Original Message - From: Us To: [EMAIL PROTECTED] Sent: Thursday, August 14, 2003 2:04 PM Subject: Thank you for registering Thank you for registering tony a href=http://www.gonefishingguideservice.com/[EMAIL PROTECTED] efishingguideservice.comconfirmation_ID=Click/a - /*the .html form which takes a name and an e-mail address */ html body form action=process_a.php method=post p Your name:br input type=text name=namebr Your e-mail address:br input type=text name=emailbr input type=submit name=submit value=submit /body /form /html ... /*process_a.php: which receives the name and email variables. The script then tries to then send the note back to the user with a link - called CLICK. When the user hits the link to email_verify.php the email address is inserted into the database*/ ? $msg = Thank you for registering $name\n\n; $msg .= a href=\http://www.gonefishingguideservice.com/email_verify.php?email=$email; confirmation_ID=$confirmation_IDCLICK/a; $secret_variable = something_only_you_know; $confirmation_ID = md5($email.$secret_variable); $to=[EMAIL PROTECTED]; $subject=Thank you for registering; $mailheaders=From: Us; mail($to,$subject,$msg,$mailheaders); ? . // email_verify.php ? if ($_GET['confirmation_ID'] = md5($_GET['email'].$secret_variable)) { // insert the user into the database } else { // display an error message } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Repopulating forms
Opp... forgot this use htmlspecialchars( ) to fix it. It will convert your to quot; for you. So you code should look like this: ?PHP $test = htmlspecialchars (gerard's name is \gerard\); echo $test.br; echo 'input type=text name=test2 value='.$test.'br'; ? form action=test2.php method=post input type=text name=foo value= / input type=submit name=sub value=submit /form and it will work :) - Anthony Gerard L Petersen [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi My code looks like this. ?PHP $test = gerard's name is \gerard\; echo $test.br; echo 'input type=text name=test2 value='.$test.'br'; ? form action=test2.php method=post input type=text name=foo value= / input type=submit name=sub value=submit /form When i run it the bit after the quotes are truncated. Where it truncates depends on what type of quote i am using. Any ideas? Thanks Gerard -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Best PHP CMS
I'm just looking for some opinions. I've been going though sourceforge looking at different CMS systems. There are a lot of really good CMS projects out there. I'm looking for some opinions on the best ones out there. I'm obviously looking at something PHP based and using mySQL backend. Some of the features that I'd like are an easy template implementation, blog features, media gallery and something that's easy to build custom modules to add features. So far I'm looking at about 6 CMS systems, I like certain things in each of them. so what's your opinion. - Anthony -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql_real_escape_string
Larry E . Ullman [EMAIL PROTECTED] wrote in message: The mysql_real_escape_string() requires a connection to the database. The connection identifier is defined in another script so it's brought in using the global statement. Hope that helps, Larry . Thank you Larry. Now I see the variable $dbc as the connection to the database in other file which uses require_once(). Best... TR -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] mysql_real_escape_string
The following function is from Larry Ullman's PHP and mySQL on page 217 - script 6.8 - in which there is a connection to a mySQL database using PHP. My question is that I'm not sure of the global variable $dbc. If I am to understand...this made up function escape_data() will receive a piece of data - say $_POST['first_name'] - and then check if magic_quotes_gpc is turned on in the ini file. If it returned true, then stripslashes will be applied to the data - if it is not turned on, then slashes will be applied to the data variable. What is the reason that the global variable $dbc is declared in the function - I cannot find another instance of $dbc outside of the function in script 6.8. Thank you, Tony Ritter . function escape_data($data) { global $dbc; if (ini_get('magic_quotes_gpc')) { $data=stripslashes($data); } return mysql_real_escape_string($data,$dbc); } . //check for a first name if(empty($_POST['first_name'])) { $fn=FALSE; $message='pYou forgot to enter you first name/p'; } else { $fn= escape_data($_POST['first_name']); // calling the function } .. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Using eregi_replace()
Using eregi_replace(), is there a way to take out a piece of a sentence - which has spaces - and then return the new sentence? For example, to return the new sentence: hello I must be going from the original sentence: blah blah blah hello I must be going blah blah. I tried: ... ? $text=blah blah blah hello I must be going blah blah; $text= eregi_replace((hello.)(.going),$newtext,$text); echo $newtext; ? ... Thank you. Tony Ritter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Using eregi_replace()
Messju Mohr [EMAIL PROTECTED] writes: you mean $newtext= ereg_replace(.*?(hello.*going).*,\\1,$text); ?? .. Thank you but I get: Warning: REG_BADRPT: in c:\apache\htdocs\string.php on line 3 Using: . ? $text=blah blah blah hello I must be going blah blah; $newtext= eregi_replace(.*?(hello.*going).*,\\1,$text); echo $newtext; ? Regards, TR -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Using eregi_replace()
However, this works using: preg_replace() . ? $text=blah blah blah hello I must be going blah blah; $newtext= preg_replace(!.*?(hello.*going).*!,$1,$text); echo $newtext; ? Thank you all. Is there a way I can be sure of the syntax? !.*?(hello.*going).*!, // the pattern which - I think - reads as follows: !.*? // do not use any character or characters before the grouping of hello (hello.*going) // get the grouping of hello and any character after that word to going .*! // do not use any character or characters after the grouping of going - not sure why the exclamation is at the end if it is a negation symbol. Please advise. Thank you. TR $1, // the grouping $text // the original string -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] strings
In the following snippet, I'm trying to open and read a URL into the variable $contents. I'd like to use preg_replace() to return only part of that string beginning with say - regional and ending with new - but I get the complete URL string returned. Thank you for any assistance. Tony Ritter ... ? $theurl=http://weather.noaa.gov/pub/data/summaries/regional/ny/albany.txt;; if (!($fp=fopen($theurl, r))) { echo Could not open the URL.; exit; } $contents=fread($fp, 100); $newtext= preg_replace(/.*?(regional.*new).*/,1,$contents); fclose($fp); echo $newtext; ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] strings
Curt Zirzow wrote in message: This exact thing was talked about earlier today, with the subject 'Using eregi_replace()'. Right. However, I've tried using the following code in which the text from the URL is printed out completely and then I change the variable from $contents to $text and using the line with preg_replace(), it still outputs the complete text without the pattern match. Any advice will be helpful. Thank you. TR ? $theurl=http://weather.noaa.gov/pub/data/summaries/regional/ny/albany.txt;; if (!($fp=fopen($theurl, r))) { echo Could not open the URL.; exit; } $contents=fread($fp, 100); fclose($fp); echo $contents; echo br; $text=$contents; $newtext= preg_replace(!.*?(REGIONAL.*YORK).*!,$1,$text); echo $newtext; // outputs the same text as above ? .. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] strings
Curt Zirzow writes: I did some testing you can see the code and results here: http://zirzow.dyndns.org/html/php/tests/preg/parse_doc.php .. Thanks Curt. I checked it out and I still pick up the following lines which I was looking to delete on the pattern match. They are: . Expires:No;;725283 //line 1 AWUS41 KALY 012014 //line 2 RWSALB // line 3 . It could be that when the URL file is being opened and read that these characters are on _three_ different_ lines as opposed to one line/string and the match is not being met. I was looking to delete those lines and to start the match at REGIONAL. Best... TR -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] anchor in php page
I am trying to access a page published on a server - and then using an anchor - to jump to a specific paragraph on that page. For instance, if using asp, I could write: www.thesite.com/thepage.asp?go=here where here -the value - in the string query would be marked up as: ... // thepage.asp a name=here blah,blah,blah, etc... /a ... Can this be done using php? Thank you. Tony Ritter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: anchor in php page
Ivo: Why not use : www.thesite.com/thepage.asp#here . Thank you Ivo. I don't usually use asp but was wondering if the word go in asp like: www.thesite.com/thepage.asp?go=here is a _reserved_ word in .asp which acts like the symbol # - serving as the anchor. And if one can achieve this using php. Thank you. TR -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Recovering from a time out
change PHP's timeout value in php.ini : max_execution_time = 30 ; Maximum execution time of each script, in seconds max_input_time = 60 ; Maximum amount of time each script may spend parsing request data don't know if you can have php do something like load a different script or a basic HTML page on timeout. That would be pretty cool though, anyone know? - Anthony Gerard Samuel [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Is it possible to *gracefully* recover from php timing out? For example, uploading a large file, and php times out, so display Oops Timed out This also assumes that we have no means of changing php's time out value?? Thanks for your comments.. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Please dirrect me -- headers ????
This isn't necessarily PHP specific, but I'm looking for more information on HTTP headers. I'd like to know what headers I should send and why. I want my code to send out w3c compliant HTML. I'm confused on exactly what headers do, and the difference between HTTP headers and information contained within the HEAD tag. Multiple google searches have gotten me only more confused. Someone please send me in the right direction :) on an a possible similar note, I have a domain name www.mydom1.com and when the user goes to it, I want it so say www.mydom.com in the browser address bar. Can I do this by sending certain headers? (I have both domains pointing to the same server) ... should/could I do something like this through PHP or is there something I can set in Apache to do the same thing? Simply confused, - Anthony -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Strange Problem
You'll get this in IIS if you request a page that should be parsed by the PHP CGI that does not exist. IIS trys to load the script into the CGI but gets no results since there was no page to load. I think it's an IIS bug i.e. you go to www.domain.com/page1.php but there is no page1.php file. So you'd expect to get a 404 error. but IIS gives you the CGI error instead. Kinda sucks, I just use Apache now anyway, so I never spent the time to figure out why. - Anthony Haseeb [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi all, this is a very strange problem. i don't know where i am doing something that is causing this. the problem is that i am working on a web portal entirely in php. i have a few hidden pages. that do the queries to the DB. now when i redirect to any page for query i get this error CGI Error The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are: strangely when i hit F5 or refresh the page i get redirected to the desired page. i have checked for any whitespaces. there are none. i have checked and double checked this. i am using win2k,IIS, php 4.3.0 again i have checked all the files for any space left that could be causing problem but i found none. i hope i make my self clear. Haseeb IncrediMail - Email has finally evolved - Click Here
Re: [PHP] Please dirrect me -- headers ????
Thanks for the links, I'm going through them now as far as the location thing. I don't acutaly want to send the user to a different site, I just want to change what apears in the user's address bar. in my example, both www.mydom1.com and www.mydom.com point to the same site and weberver. It's simply that one is the old address, and I want users to see teh new address, even if they type in the old one. - Anthony Ryan Gibson [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi, Headers have nothing to do with the head tag, the headers are sent before the html page, ie they are not part of the html document, but something sent by the web server before the page is sent to the user Try: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html And http://www.cs.tut.fi/~jkorpela/http.html As for question 2, if you want to redirect the user to the other website use the location header to redirect them to the other site (otherwise you'll have to redirect them to the other site, then use frames to open the content on the original site) On 14/7/03 5:16 pm, Anthony [EMAIL PROTECTED] wrote: This isn't necessarily PHP specific, but I'm looking for more information on HTTP headers. I'd like to know what headers I should send and why. I want my code to send out w3c compliant HTML. I'm confused on exactly what headers do, and the difference between HTTP headers and information contained within the HEAD tag. Multiple google searches have gotten me only more confused. Someone please send me in the right direction :) on an a possible similar note, I have a domain name www.mydom1.com and when the user goes to it, I want it so say www.mydom.com in the browser address bar. Can I do this by sending certain headers? (I have both domains pointing to the same server) ... should/could I do something like this through PHP or is there something I can set in Apache to do the same thing? Simply confused, - Anthony Ryan Gibson --- [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Please dirrect me -- headers ????
yes, I can edit the httpd.conf file. I'm looking in the Apache 2.0 docs and can't find the server directive. Also, to my knowledge and according to the docs, alias mydom.com is invalid. Alias URL-path file-path|directory-path is how the docs explain it. Am I missing something. If I can do this through Apache. it would probably be much simpler. - Anthony Apache 2.0.45 by the way :) Taylor York [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Cant you edit the httpd.conf? I know there might be plenty of reasons why not to...but im just checking. =) Server mydom1.com Alias mydom.com Anthony [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Thanks for the links, I'm going through them now as far as the location thing. I don't acutaly want to send the user to a different site, I just want to change what apears in the user's address bar. in my example, both www.mydom1.com and www.mydom.com point to the same site and weberver. It's simply that one is the old address, and I want users to see teh new address, even if they type in the old one. - Anthony Ryan Gibson [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi, Headers have nothing to do with the head tag, the headers are sent before the html page, ie they are not part of the html document, but something sent by the web server before the page is sent to the user Try: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html And http://www.cs.tut.fi/~jkorpela/http.html As for question 2, if you want to redirect the user to the other website use the location header to redirect them to the other site (otherwise you'll have to redirect them to the other site, then use frames to open the content on the original site) On 14/7/03 5:16 pm, Anthony [EMAIL PROTECTED] wrote: This isn't necessarily PHP specific, but I'm looking for more information on HTTP headers. I'd like to know what headers I should send and why. I want my code to send out w3c compliant HTML. I'm confused on exactly what headers do, and the difference between HTTP headers and information contained within the HEAD tag. Multiple google searches have gotten me only more confused. Someone please send me in the right direction :) on an a possible similar note, I have a domain name www.mydom1.com and when the user goes to it, I want it so say www.mydom.com in the browser address bar. Can I do this by sending certain headers? (I have both domains pointing to the same server) ... should/could I do something like this through PHP or is there something I can set in Apache to do the same thing? Simply confused, - Anthony Ryan Gibson --- [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Please Help !
look up two functions in the online manual. strtotime() and date() strtotime will give you a unix timestamp for just about any date possable, date will format it the way you need. to get it into a mySQL date field, basicaly, you do this: date(y-m-d, strtotime($_POST['date'])) where $_POST['date'] is whatever variable you used. - Anthony Sean O'Reilly [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi, I know this is really basic but i have a form for users to enter the date of an event that i would like to store in a mysql database how do i get the users input into the database in the right format. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: php my sql question
When you upload the page to the webserver and then access it, do you just see the source? If so then you probably don;t have PHP support as part of your hosting package. Call your web host and find out. Also, if you're really new to PHP, I'll through this out too, you did put ?PHP ? arround your script right? Once you're sure PHP is running, then check out the online manual for MySQL functions -- http://us2.php.net/manual/en/ref.mysql.php You don't need PHP on your local machine, just on the webserver. It may be a good idea though to install a webserver (like Apache) and PHP on your local machine, that way you can test your scripts without uploading them to the webserver. - Anthony Jerome A. Jackson/Ac/Vcu [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I have a web site that has my sql installed. The web server is 1st host web and they do not provide much support other than referral to my sql and php web site. I know how to set up a database from a text file then upload to an sql database. Now I want to write code to make it open and access it. This is where I am stuck. The web site uses an apache server. Must I install php on my local machine? When I save a web page with a php extension, it defaults to an html page and it will not work when I upload. -- Jerome A. Jackson Information Services Coordinator Advancement Services Virginia Commonwealth University Post Office Box 842026 Richmond, Virginia 23284-2026 Phone: 804-828-2043 Fax: 804-828-0884 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Calculating Largest Member of Array
why not just change your array structure a little so that the date is the key, and the elements are the values. so it would look like this. Array ( [Jan-99] = Array ( [0] = 6399.36 [1] = 6132.71 [2] = 2242.20 [3] = 53.27 [4] = 87.34 ) [Feb-99] = Array ( [0] = 5754.72 [1] = 3964.93 [2] = 6145.98 [3] = 693.32 [4] = 23.80 ) ) That would make it much easier. I think. - Anthony John Wulff [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Sorry for the multiple post!! Apparently when pasting I hit some magic send key.I'd like to calculate the largest member of this array without taking into account the first value which is obvisouly not numeric. So far this is how I'm doing it, but sometimes I get returned a month for the max. $high = end(array_reduce($cdata, create_function('$a, $b', 'return array(max(array_reduce($a, max), array_reduce($b, max)));'))); Array ( [0] = Array ( [0] = Jan-99 [1] = 6399.36 [2] = 6132.71 [3] = 2242.20 [4] = 53.27 [5] = 87.34 ) [1] = Array ( [0] = Feb-99 [1] = 5754.72 [2] = 3964.93 [3] = 6145.98 [4] = 693.32 [5] = 23.80 ) ) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP + Linux: Configuration?
Not 100% sure, but isn't $HTTP_POST_VARS depricated?... to lazy to look in the manual right now. You should use $_POST instead. I have no idea if that's causing your problem though :-P - Anthony Luiz Morte [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hello list, I have a problem using php in linux. I´m using the code bellow: html code: form name=texto METHOD=POST ACTION=a.php textarea name=teste cols=120 rows=10 wrap=OFF/textarea pinput name=Enviar type=submit/p /form php code ?php $tmp= $HTTP_POST_VARS['teste']; $linhas = split(\n, $tmp); printf (Nro de linhas = %dbr,count($linhas)); ? If I repeat the line bellow 100 times and put this in a textarea, the php code returns that there are 154 lines. teste.com.br::Teste variaveis::teste::teste::dfasfafasdfafasdfasfas::11::11::ativo::teste.do.tes te I´ve made this test using the versions: php-4.2.2-17 php-4.3.2-3 Using FreeBSD, I don´t have the error with the same code. (php-4.3.1) Any ideia? Thanks in advance, Luiz. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Get Rid of this Crook
pathetic isn't it :-/ - Anthony Doug Essinger-Hileman [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On 3 Jul 2003 at 9:06, Adam Voigt wrote: Well spamming doesn't get them any money. I believe I read they use this info to transfer money from your bank account, after convincing you to scan your passport for them, or something like that. Actually, the scam is fairly sophisticated. They ask for money upfront in order to begin the process of getting access to the loot that is stored whereever. Usually, they ask for one or two more payments, since it is costing them more than they thought. They then inform you that the money you sent them has been used to bribe officials, including those in the government. If you don't send them even more money, they will report you to the authorities on suspicion of bribery and have you arrested. At this point, the scam becomes simple blackmail. Most interesting to me is that this scam is so widespread (a sign that it is successful) that the FBI has stationed some agents in Nigeria solely for the purpose of dealing with this scam. Apparently, there are some folk so greedy that gullibility wins the day. Doug -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: web based mail client
In addition to using an elready developed web mail client. If you plan to have a large number of users, you might want to go with some type of completely managed packaged software. I was reading about Novell NetMail. Check it out, even runs on Linux now too -- http://www.novell.com/products/netmail/ Don't know how customiseable it is or if you could use PHP to extend it, but its worth a look. - Anthony Pete Morganic [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] There's loads of email clients here http://www.hotscripts.com/PHP/Scripts_and_Programs/Email_Systems/Web-based_E mail/index.html Greg Brant wrote: hi, im the lead developer for a small online magazine / community we want to set up an e-mail service where our users can create their own mail account similar to hotmail etc etc. i plan on using the imap_ functions and i was just wondering about the potential security issues related to theses functions. any advice or tips would be appreciated. many thanks Greg Brant -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php