[PHP] PHP Imagefill
Is there a way to specify an already existing file to use as the background, instead of a specific color, such as what http://ca.php.net/manual/en/function.imagefill.php illustrates? Ron
[PHP] Matching
How do I determine the value oftx from this string? page/words_from_the_well_checkout/?tx=8UM53005HH344951T&st=Completed&amt=0.01 My desired answer is: 8UM53005HH344951T I am trying to capture the serial number which follows tx= and ends immediately before the & Ron
[PHP] Another matching question
How do I tell if words_from_the_well is not the value of $page (whether it is the entire value of $page OR within the value of $page) So far I have come up with the following, but it doesn't deal with when $page is only within the value of $page if ( $page <> "words_from_the_well" ) { Ron
[PHP] Pausing PHP scripts
Is there a way to pause a PHP script while it is executing? Ron
[PHP] PHP and making a ZIP file
Does anyone know how to make a ZIP file using PHP? This is for an application where the files the user selected will be put into a ZIP file and then the ZIP file made available for download. Ron
[PHP] $_GET
I am moving my web site to a new host this weekend. I am working towards making the code compatible to the structure of the new server. I am getting a weird response which I don't understand At the very start of my index.php I have the following lines of code: foreach($_GET as $key => $val) { $$key = $_GET[$val]; echo $_GET[$val] . ""; } What I don't understand is why the output is I am not understanding how two "empty" variables are being passed. index.php is driven off of various mod re-writes contained within .htaccess . This is why I am doing the loop above. RewriteRule ^page/([^/\.]+)/?$ index.php?page=$1 [L] RewriteRule ^page/([^/\.]+)/([^/\.]+)/?$ index.php?page=$1&field1=$2 [L] RewriteRule ^page/([^/\.]+)/([^/\.]+)/([^/\.]+)/?$ index.php?page= $1&field1=$2&field2=$3 [L] What should I be trying? What will allow the value of page to be passed onto $page with the following URL: http://www.actsministrieschristianevangelism.org/page/home_page/
[PHP] $_GET verses $_POST
How do I know when to use $_GET verses $_POST? Is there a pre defined variable that does both? Ron
Re: [PHP] $_GET verses $_POST
Thanks. I got my script updated. Ron On Sun, 2009-04-12 at 22:33 +0600, 9el wrote: > > > > One thing you should know is that when you use $_GET, you'll > be sending a little information about the particular page to > the browser and therefore it would be displayed in the address > bar so for example if you're using get on a login page, you'll > be showing user id and passwrod in the address bar. $_POST > does the exact opposite of $_GET in that aspect and it's > ideal. $_REQUEST does both. > > > Its also important to know that some critical information like > multipart meta data cant be sent via get. And GET method is not safe > too. > Large chunks of data are sent via POST method. > > $_REQUEST is not advised to use for security reasons.. there are > senior and experienced programmers here who will elaborate more onto > this :) >
[PHP] DATE / strtotime
Where $date_reference is 2009-04-18 the following code gives me a day of 1969-12-30. How do I get it to be 2009-04-17? $previous_date = strtotime("-1 days", $date_reference); $previous_date = date('Y-m-d', $previous_date); echo $previous_date; outputs 1969-12-30 Ron
Re: [PHP] DATE / strtotime
Thanks Chris. It has been a while since I used this command. Ron On Mon, 2009-04-20 at 13:27 +1000, Chris wrote: > Ron Piggott wrote: > > Where $date_reference is 2009-04-18 the following code gives me a day of > > 1969-12-30. How do I get it to be 2009-04-17? > > > > $previous_date = strtotime("-1 days", $date_reference); > > $previous_date = date('Y-m-d', $previous_date); > > Slightly wrong syntax. > > $previous_date = strtotime("$date_reference -1 days"); >
[PHP] SMTP mail server
How do I specify an actual SMTP server? (Like mail.host.com) This is what I have so far: mail($email, $subject, $message, $headers); I was to http://ca2.php.net/manual/en/function.mail.php and saw this syntax: mail ( string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]] ) Ronhttp://
Re: [PHP] SMTP mail server
I am on a shared web site hosting company. They are asking me to edit my PHP script to specify the SMTP using $aditional_parameters on the URL below. If this can't be achieved then I need to confirm this. Ron On Fri, 2009-04-24 at 20:04 -0500, Adam Williams wrote: > > Ron Piggott wrote: > > How do I specify an actual SMTP server? (Like mail.host.com) > > > > This is what I have so far: > > > > mail($email, $subject, $message, $headers); > > > > I was to http://ca2.php.net/manual/en/function.mail.php and saw this > > syntax: > > > > mail ( string $to , string $subject , string $message [, string > > $additional_headers [, string $additional_parameters ]] ) > > > > Ronhttp:// > > > > > http://www.php.net/manual/en/mail.configuration.php > > looks like you can edit php.ini and change SMTP=localhost to something > else and restart apache (if needed) >
Re: [PHP] SMTP mail server
I am needing to put this into one specific PHP script. What would the ini_set look like? Ron On Sat, 2009-04-25 at 06:43 +0530, kranthi wrote: > if u cant change the configuration settings of php.ini > use http://pear.php.net/package/Mail > alternatively u can also hav ini_set on top of every page.
[PHP] Inline images with PEAR Mail
I am not understanding how to do inline images with the PEAR Mail module. I am new to using this PEAR Mail module. I give the command: $mime -> addHTMLImage("/home/thev4173/public_html/images/email_cross.gif"); It offers the image as a file attachment, and not displaying it within the context of the HTML e-mail: What additional step(s) am I needing to take? Ron
[PHP] Fractions
Is there a way to remove the trailing '0'? Also is there a way to have the original fraction display (1/4), as well as have provision for 1/8 and 3/8 and 1/2, etc. display? Width: 2.250" x Height: 6.250" Ron
[PHP] Re: Fractions
This is what I came up with, it may help some of you working with US measurements. $interval = array(0.125 => '1/8', 0.25 => '1/4', 0.375 => '3/8', 0.5 => '1/2', 0.625 => '5/8', 0.75 => '3/4', 0.875 => '7/8'); echo "Width: " . intval($product_width_inch) . " " . $interval[$product_width_inch-intval($product_width_inch)] . "" x Height: " . intval($product_height_inch) . " " . $interval[$product_height_inch-intval($product_height_inch)] . """; On Sun, 2009-05-24 at 18:03 -0400, Ron Piggott wrote: > > Is there a way to remove the trailing '0'? > > Also is there a way to have the original fraction display (1/4), as > well as have provision for 1/8 and 3/8 and 1/2, etc. display? > > Width: 2.250" x Height: 6.250" > > Ron
[PHP] str_replace
Am I understanding str_replace correctly? Do I have this correct or are ' needed? $bible_verse_ref is what I want to change to (AKA replace) bible_verse_ref is what I change to change from (AKA search) $text_message_template is the string I want to manipulate $text_message = str_replace( $bible_verse_ref, 'bible_verse_ref', $text_message_template ); Ron
Re: [PHP] str_replace
Yes I did. Thank you for confirming this with me. Ron - Original Message - From: "LinuxManMikeC" To: "Ron Piggott" Cc: ; Sent: Saturday, August 08, 2009 6:19 AM Subject: Re: [PHP] str_replace On Sat, Aug 8, 2009 at 2:08 AM, Ron Piggott wrote: Am I understanding str_replace correctly? Do I have this correct or are ' needed? $bible_verse_ref is what I want to change to (AKA replace) bible_verse_ref is what I change to change from (AKA search) $text_message_template is the string I want to manipulate $text_message = str_replace( $bible_verse_ref, 'bible_verse_ref', $text_message_template ); Ron If I understand you right, I think you have the search and replace arguments mixed up. Your current code will look for all occurrences of $bible_verse_ref in $text_message_template and replace it with 'bible_verse_ref'. http://us.php.net/manual/en/function.str-replace.php No virus found in this incoming message. Checked by AVG - www.avg.com Version: 8.5.392 / Virus Database: 270.13.47/2289 - Release Date: 08/07/09 18:37:00 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Array
How do I change this ELSEIF into an array? } elseif ( ( $page <> "" ) AND ( $page <> "home_page" ) AND ( $page <> "verse_of_the_day_activate" ) AND ( $page <> "member_services" ) AND ( $page <> "member_services_login" ) AND ( $page <> "member_services_logoff" ) AND ( $page <> "resource_center" ) AND ( $page <> "network" ) ) {
[PHP] Rounding down?
Is there a way to round down to the nearest 50? Example: Any number between 400 and 449 I would 400 to be displayed; 450 to 499 would be 450; 500 to 549 would be 500, etc? The original number of subscribers is from a mySQL query and changes each day. I am trying to present a factual statement: "There have been over ### subscribers in 2009" type of scenereo. Ron
Re: [PHP] Rounding down?
Thanks; Amazing. Ron - Original Message - From: "Ashley Sheridan" To: "Richard Heyes" Cc: "Ron Piggott" ; Sent: Saturday, August 22, 2009 9:02 AM Subject: Re: [PHP] Rounding down? On Sat, 2009-08-22 at 13:00 +0100, Richard Heyes wrote: Hi, > Is there a way to round down to the nearest 50? > > Example: Any number between 400 and 449 I would 400 to be displayed; > 450 to 499 would be 450; 500 to 549 would be 500, etc? Off the top of my head: divide the number by 50, run floor() on the result, then times it by 50. 1. 449 / 50 = 9.whatever 2. floor(9.whatever) = 9 3. 9 * 50 = 450 -- Richard Heyes HTML5 graphing: RGraph - www.rgraph.net (updated 8th August) Lots of PHP and Javascript code - http://www.phpguru.org It should be round() and not floor(). 449 / 50 = 8.98 floor(8.98) = 8 8 * 50 = 400 round(8.98) = 9 9 * 50 = 450 Thanks, Ash http://www.ashleysheridan.co.uk No virus found in this incoming message. Checked by AVG - www.avg.com Version: 8.5.409 / Virus Database: 270.13.64/2319 - Release Date: 08/22/09 06:06:00 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Network Time Protocol
Where could I get instructions to set up a network time protocol through my web site hosting server? Ron -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] DATE
I have date in the variable $date_reference in the format -MM-DD. How do I find out the date before this and the date after this? Ron -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] DATE
Someone sent me the strtotime function. This was the command I was needing. Ron On Sun, 2007-01-28 at 08:57 -0600, David Giragosian wrote: > Ron Piggott wrote: > > I have date in the variable $date_reference in the format > -MM-DD. > > How do I find out the date before this and the date after > this? Ron > > > > Not enough information, Ron. Do you mean: 1. as exists in some data > set that you've created or stored, like in an array or a database; 2. > in a general sense, like a millisecond before and after, as in some > increment/decrement of linear time; 3. some other conceptual > understanding of time, before and after? > > David > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] IF loop
Would someone help me tweak the IF statement below? I am trying to assign a value to $seasonal_greeting on Good Friday, Saturday and Easter Sunday. We had added an extra day's worth of seconds to $Easter_Sunday wondering if this is why it didn't work on Easter Sunday. Where I am at today --- the IF loop is assigning a value to $seasonal_greeting, not the desired results. Please e-mail me directly any modifications that should be made to these lines of code below. [EMAIL PROTECTED] Thanks, Ron $current_year=date("Y"); $date_reference=time(); $good_Friday = easter_date($current_year)-24*3600*2; $Easter_Sunday = easter_date($current_year)*60*60*24; if ($date_reference >= $good_Friday && $date_reference <= $Easter_Sunday) { $seasonal_greeting = "Have a blessed Easter Weekend celebrating Jesus' love for you on the cross"; }
[PHP] Array
The following line gives me an error message when there aren't any values in the array --- how do I accommodate this? Warning: Invalid argument supplied for foreach() foreach ($_SESSION['order'] AS $key => $value ) { -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] $_SESSION variables
Instead of doing: $_SESSION['order'][$reference]['quantity'] = 0; Is there a way to get remove that part of the array altogether? Ron -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $_SESSION variables
I am programming a shopping cart. So far I have used $_SESSION['order'][$reference]['quantity'] = 0; if the customer changed their mind about buying an item. Is there a way to remove the session variable altogether? Ron -Original Message- From: Ashley Sheridan Reply-to: a...@ashleysheridan.co.uk To: ron@actsministries.org Cc: PHP General Subject: Re: [PHP] $_SESSION variables Date: Sat, 24 Oct 2009 12:52:17 +0100 On Sat, 2009-10-24 at 07:52 -0400, Ron Piggott wrote: > Instead of doing: > > $_SESSION['order'][$reference]['quantity'] = 0; > > Is there a way to get remove that part of the array altogether? > > Ron > > I don't understand your question.. Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] Array
The code I have so far for orders is below. When a product hasn't been added it does what I want it to --- in giving the message "Your shopping cart is empty". When a product is added, but then the user changes their mind I use the following lines of code to remove the selection: UNSET($_SESSION['order'][$reference]['quantity']); UNSET($_SESSION['order'][$reference]); It still leaves the variable $_SESSION['order'] as an array, even if there are no selections in it. The PHP command is_array is useless of weed out when there are no products. What I would like to have happen is if the shopping cart is empty then the message "Your shopping cart is empty" be displayed 100% of the time. How do I achieve this? What changes to my code below need to happen? $value ) { echo "Product: " . $key . " Quantity: " . $_SESSION['order'][$key]['quantity'] . "\r\n"; } } else { #no products selected echo "\r\n"; echo "Your shopping cart is empty\r\n"; echo "\r\n"; } -Original Message- From: Martin Scotta To: a...@ashleysheridan.co.uk Cc: ron.pigg...@actsministries.org, PHP General Subject: Re: [PHP] Array Date: Sat, 24 Oct 2009 11:50:14 -0300 On Sat, Oct 24, 2009 at 7:59 AM, Ashley Sheridan wrote: On Sat, 2009-10-24 at 06:57 -0400, Ron Piggott wrote: > The following line gives me an error message when there aren't any > values in the array --- how do I accommodate this? > > Warning: Invalid argument supplied for foreach() > > foreach ($_SESSION['order'] AS $key => $value ) { > > Do an isset() on $_SESSION['order'] first to determine if the variable even exists, then do is_array() to determine if it's an array or not before trying to iterate it. My guess is that $_SESSION['order'] isn't an array all the time. Thanks, Ash http://www.ashleysheridan.co.uk foreach works with array and instances. Unless the class implements Transversable, it's public properties are used on the loop. foreach($object as $prop => $value ) //php translates the foreach into something like this... foreach(get_object_vars($object) as $prop => $value ) -- Martin Scotta
Re: [PHP] Array
AHH. The count() command does the trick. Ron -Original Message- From: Ron Piggott Reply-to: ron.pigg...@actsministries.org To: Martin Scotta , phps...@gmail.com Cc: a...@ashleysheridan.co.uk, PHP General Subject: Re: [PHP] Array Date: Sat, 24 Oct 2009 11:43:12 -0400 The code I have so far for orders is below. When a product hasn't been added it does what I want it to --- in giving the message "Your shopping cart is empty". When a product is added, but then the user changes their mind I use the following lines of code to remove the selection: UNSET($_SESSION['order'][$reference]['quantity']); UNSET($_SESSION['order'][$reference]); It still leaves the variable $_SESSION['order'] as an array, even if there are no selections in it. The PHP command is_array is useless of weed out when there are no products. What I would like to have happen is if the shopping cart is empty then the message "Your shopping cart is empty" be displayed 100% of the time. How do I achieve this? What changes to my code below need to happen? $value ) { echo "Product: " . $key . " Quantity: " . $_SESSION['order'][$key]['quantity'] . "\r\n"; } } else { #no products selected echo "\r\n"; echo "Your shopping cart is empty\r\n"; echo "\r\n"; } -Original Message- From: Martin Scotta To: a...@ashleysheridan.co.uk Cc: ron.pigg...@actsministries.org, PHP General Subject: Re: [PHP] Array Date: Sat, 24 Oct 2009 11:50:14 -0300 On Sat, Oct 24, 2009 at 7:59 AM, Ashley Sheridan wrote: On Sat, 2009-10-24 at 06:57 -0400, Ron Piggott wrote: > The following line gives me an error message when there aren't any > values in the array --- how do I accommodate this? > > Warning: Invalid argument supplied for foreach() > > foreach ($_SESSION['order'] AS $key => $value ) { > > Do an isset() on $_SESSION['order'] first to determine if the variable even exists, then do is_array() to determine if it's an array or not before trying to iterate it. My guess is that $_SESSION['order'] isn't an array all the time. Thanks, Ash http://www.ashleysheridan.co.uk foreach works with array and instances. Unless the class implements Transversable, it's public properties are used on the loop. foreach($object as $prop => $value ) //php translates the foreach into something like this... foreach(get_object_vars($object) as $prop => $value ) -- Martin Scotta -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] stristr query trouble
I am not understanding why 'true' isn't the result of this syntax because $subjects equals: $subjects = "Delivery Status Notification(Failure)"; Here is my syntax: if ( stristr( $subjects, "Delivery Status Notifcation(Failure)" ) ) { $TIRSFlag = true; echo "true"; }
[PHP] Parse question
If $message_body contains: $message_body="You are subscribed using u...@domain. To update"; How do I capture just the e-mail address? Ron
[PHP] Array form processing
I am trying to process a form where the user uses checkboxes: Sharp Stabbing Jabbing When I do: foreach($_REQUEST as $key => $val) { $$key = $val; echo $key . ": " . $val . ""; } The output is: painDesc: Array I need to know the values of the array (IE to know what the user is checking), not that there is an array. I hope to save these values to the database. Thank you. Ron -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Array form processing
Am I on the right track? I don't know what to do with the second "FOREACH" $val) { $$key = $val; echo $key . ": " . $val . ""; if ( $val == "Array" ) { $i=0; foreach ($val) { echo "$val[$i]"; $i++; } } } ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Array / form processing
I am writing a custom shopping cart that eventually the "cart" will be uploaded to PayPal for payment. I need to be able to include the option that the purchase is a gift certificate. At present my "add to cart" function goes like this: === # Gift Certificate: 1 is a gift; 2 is personal use if ( $gift_certificate == "yes" ) { $gift = 1; } else { $gift = 2; } $_SESSION['life_coaching_order'][$product][$gift]['quantity'] = $_SESSION['life_coaching_order'][$product][$gift]['quantity'] + 1; === Now I need to display the shopping cart contents. I want to do this through an array as the contents of the shopping cart are in a session variable. I start displaying the shopping cart contents by a "FOREACH" loop: === foreach ($_SESSION['life_coaching_order'] AS $coaching_fee_theme_reference => $value ) { === What I need help with is that I don't know how to test the value of $gift in the above array if it is a 1 or 2 (which symbolizes this is a gift certificate). I have something like this in mind: if ( $_SESSION['life_coaching_order'] == 2 ) { But I don't know how to access all the components of the array while I am going through the FOREACH loop. By using a "1" or "2" I have made gift certificates their own product. If you a better method I could use please provide me with this feedback. Ron The Verse of the Day Encouragement from God's Word www.TheVerseOfTheDay.info -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Array / form processing
Many thanks, Chris. I have one additional question about this shopping cart project. I need to make a submit button for the purpose of removing an item from the shopping cart. What I am struggling with is to find an effective method for passing the product serial number (auto_increment in the table it is stored in) so I know which product the user is removing from their purchase. Then I will just unset the session variable that matches. What are your suggestion(s)? Thank you your help with my original question Chris. Ron > $_SESSION['life_coaching_order'][$product][$gift]['quantity'] = > $_SESSION['life_coaching_order'][$product][$gift]['quantity'] + 1; > === > > ... > > === > foreach ($_SESSION['life_coaching_order'] AS $coaching_fee_theme_reference > => $value ) { > === > > > In this example $value would be an array. To test if it is a gift or not > you > would do this from within the foreach loop: > > //gift > if ( isset($value[1]) && isset($value[1]['quantity']) ) > { > $gift_quantity = $value[1]['quantity']; > } > > //personal use > if ( isset($value[2]) && isset($value[2]['quantity']) ) > { > $personal_quantity = $value[2]['quantity']; > } > > > Technically the above IF's are optional, but they are proper syntax. > > I don't know how you are with OOP, but you may have more luck using > objects > instead of a complex array. > > Chris H. > > > On Thu, Oct 7, 2010 at 3:35 PM, Ron Piggott > wrote: > >> >> I am writing a custom shopping cart that eventually the "cart" will be >> uploaded to PayPal for payment. I need to be able to include the option >> that the purchase is a gift certificate. >> >> >> >> At present my "add to cart" function goes like this: >> >> === >> # Gift Certificate: 1 is a gift; 2 is personal use >> >> if ( $gift_certificate == "yes" ) { >>$gift = 1; >> } else { >>$gift = 2; >> } >> >> $_SESSION['life_coaching_order'][$product][$gift]['quantity'] = >> $_SESSION['life_coaching_order'][$product][$gift]['quantity'] + 1; >> === >> >> Now I need to display the shopping cart contents. I want to do this >> through an array as the contents of the shopping cart are in a session >> variable. I start displaying the shopping cart contents by a "FOREACH" >> loop: >> >> === >> foreach ($_SESSION['life_coaching_order'] AS >> $coaching_fee_theme_reference >> => $value ) { >> === >> >> What I need help with is that I don't know how to test the value of >> $gift >> in the above array if it is a 1 or 2 (which symbolizes this is a gift >> certificate). >> >> I have something like this in mind: >> if ( $_SESSION['life_coaching_order'] == 2 ) { >> >> But I don't know how to access all the components of the array while I >> am >> going through the FOREACH loop. >> >> By using a "1" or "2" I have made gift certificates their own product. >> If >> you a better method I could use please provide me with this feedback. >> >> Ron >> >> The Verse of the Day >> Encouragement from God's Word >> www.TheVerseOfTheDay.info >> >> >> -- >> PHP General Mailing List (http://www.php.net/) >> To unsubscribe, visit: http://www.php.net/unsub.php >> >> > The Verse of the Day Encouragement from God's Word www.TheVerseOfTheDay.info -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: String manipulation
How would I write an IF statement that looks for the first space space (“ “) left of the 76th character in a string or , which ever comes first --- OR the end of the string (IE the string is less than 76 characters long? I specifically want is it’s character position in the string. Ron The Verse of the Day “Encouragement from God’s Word” http://www.TheVerseOfTheDay.info
Re: [PHP] Re: String manipulation
I am receiving this error: Warning: strpos() [function.strpos]: Offset not contained in string I have never seen it before, what do I do? I made one change to it though, you didn’t have in it before so I changed the syntax to: $pos = (strpos(' ', $activity_description_result, 76))?strpos('',$activity_description_result, 76):strlen($activity_description_result); Ron The Verse of the Day “Encouragement from God’s Word” http://www.TheVerseOfTheDay.info From: a...@ashleysheridan.co.uk Sent: Sunday, November 14, 2010 4:58 PM To: Ron Piggott ; php-general@lists.php.net Subject: Re: [PHP] Re: String manipulation What about something like this: $pos = (strpos(' ', $string, 76))?strpos(' ',$string, 76):strlen($string); Thanks, Ash http://www.ashleysheridan.co.uk - Reply message - From: "Ron Piggott" Date: Sun, Nov 14, 2010 20:48 Subject: [PHP] Re: String manipulation To: How would I write an IF statement that looks for the first space space (“ “) left of the 76th character in a string or , which ever comes first --- OR the end of the string (IE the string is less than 76 characters long? I specifically want is it’s character position in the string. Ron The Verse of the Day “Encouragement from God’s Word” http://www.TheVerseOfTheDay.info
[PHP] Returning values from a function
I am writing a string parsing function. I need to return 3 values from a function: return $string_to_display; return $string_to_parse; return $continue_parsing; I am not sure how to retrieve these variables. The Verse of the Day “Encouragement from God’s Word” http://www.TheVerseOfTheDay.info
[PHP] Retrieving function values
I am writing a custom function and I need to be able to retrieve 3 values from it. string_parse_tool ( $string_to_parse ) The 3 variables I need to retrieve from the function are: $string_to_parse $string_to_display $continue_parsing I only know how to retrieve 1 variable from a function, not 3. Could someone help me please? Thank you. Ron
[PHP] Suppressing error from displaying
I am using this syntax to check for a valid e-mail address list($userName, $mailDomain) = split("@", $buyer_email); if (checkdnsrr($mailDomain, "MX")) { if no domain is provided ( ie e-mail address is something like “ron” with no @ ) the following error is displayed: Warning: checkdnsrr() [function.checkdnsrr]: Host and type cannot be empty Can I suppress this from displaying so *just* my error message displays? Ron The Verse of the Day “Encouragement from God’s Word” http://www.TheVerseOfTheDay.info
[PHP] Fw: Spoofing user_agent
I have wrote a script to generate a sitemap of my web site. It crawls all of the site web pages. (About 30,000) I need help to spoof the user_agent variable so the stats program running in the background ( “AWSTATS” ) will treat the crawl as a bot, not browsing usage. The sitemap generator is a cron job. I tried the syntax: ini_set('user_agent', 'RonBot (http://www.theverseoftheday.info)'/); This didn’t work. The browsing was attributed to the dedicated IP address. How do I get AWSTATS to access this, such as other entries under the “Robots/Spiders visitors” heading: Unknown robot (identified by 'bot*') I don’t mean any ill will by changing this setting. Thanks for the help. Ron The Verse of the Day “Encouragement from God’s Word” http://www.TheVerseOfTheDay.info
Re: [PHP] Fw: Spoofing user_agent
Is this what you are telling me to do: header('user_agent: RonBot (http://www.theverseoftheday.info)'); Ron The Verse of the Day “Encouragement from God’s Word” http://www.TheVerseOfTheDay.info From: a...@ashleysheridan.co.uk Sent: Thursday, November 25, 2010 3:34 AM To: Ron Piggott ; php-general@lists.php.net Subject: Re: [PHP] Fw: Spoofing user_agent You need to set it in the header request you make. Putting it in the script you're using as a spider with ini_set won't do anything because the Target site doesn't know anything about it. Thanks, Ash http://www.ashleysheridan.co.uk - Reply message - From: "Ron Piggott" Date: Thu, Nov 25, 2010 08:25 Subject: [PHP] Fw: Spoofing user_agent To: I have wrote a script to generate a sitemap of my web site. It crawls all of the site web pages. (About 30,000) I need help to spoof the user_agent variable so the stats program running in the background ( “AWSTATS” ) will treat the crawl as a bot, not browsing usage. The sitemap generator is a cron job. I tried the syntax: ini_set('user_agent', 'RonBot (http://www.theverseoftheday.info)/'/); This didn’t work. The browsing was attributed to the dedicated IP address. How do I get AWSTATS to access this, such as other entries under the “Robots/Spiders visitors” heading: Unknown robot (identified by 'bot*') I don’t mean any ill will by changing this setting. Thanks for the help. Ron The Verse of the Day “Encouragement from God’s Word” http://www.TheVerseOfTheDay.info
Re: [PHP] Fw: Spoofing user_agent
Thanks. Ron The Verse of the Day “Encouragement from God’s Word” http://www.TheVerseOfTheDay.info From: Shreyas Agasthya Sent: Thursday, November 25, 2010 4:21 AM To: Ron Piggott Cc: php-general@lists.php.net ; a...@ashleysheridan.co.uk Subject: Re: [PHP] Fw: Spoofing user_agent A standard HTTP Request headers is : User Agent (without the underscore). --Shreyas On Thu, Nov 25, 2010 at 2:36 PM, Ron Piggott wrote: Is this what you are telling me to do: header('user_agent: RonBot (http://www.theverseoftheday.info)'); Ron The Verse of the Day “Encouragement from God’s Word” http://www.TheVerseOfTheDay.info From: a...@ashleysheridan.co.uk Sent: Thursday, November 25, 2010 3:34 AM To: Ron Piggott ; php-general@lists.php.net Subject: Re: [PHP] Fw: Spoofing user_agent You need to set it in the header request you make. Putting it in the script you're using as a spider with ini_set won't do anything because the Target site doesn't know anything about it. Thanks, Ash http://www.ashleysheridan.co.uk - Reply message - From: "Ron Piggott" Date: Thu, Nov 25, 2010 08:25 Subject: [PHP] Fw: Spoofing user_agent To: I have wrote a script to generate a sitemap of my web site. It crawls all of the site web pages. (About 30,000) I need help to spoof the user_agent variable so the stats program running in the background ( “AWSTATS” ) will treat the crawl as a bot, not browsing usage. The sitemap generator is a cron job. I tried the syntax: ini_set('user_agent', 'RonBot (http://www.theverseoftheday.info)/'/); This didn’t work. The browsing was attributed to the dedicated IP address. How do I get AWSTATS to access this, such as other entries under the “Robots/Spiders visitors” heading: Unknown robot (identified by 'bot*') I don’t mean any ill will by changing this setting. Thanks for the help. Ron The Verse of the Day “Encouragement from God’s Word” http://www.TheVerseOfTheDay.info -- Regards, Shreyas Agasthya
Re: [PHP] Fw: Spoofing user_agent
Will the header pass with using file_get_contents , or should I be using another command, and if so, which one? Ron http://www.example.com)'); $url = "http://www.example.com";; $input = file_get_contents($url); The Verse of the Day “Encouragement from God’s Word” http://www.TheVerseOfTheDay.info From: Shreyas Agasthya Sent: Thursday, November 25, 2010 4:21 AM To: Ron Piggott Cc: php-general@lists.php.net ; a...@ashleysheridan.co.uk Subject: Re: [PHP] Fw: Spoofing user_agent A standard HTTP Request headers is : User Agent (without the underscore). --Shreyas On Thu, Nov 25, 2010 at 2:36 PM, Ron Piggott wrote: Is this what you are telling me to do: header('user_agent: RonBot (http://www.theverseoftheday.info)'); Ron The Verse of the Day “Encouragement from God’s Word” http://www.TheVerseOfTheDay.info From: a...@ashleysheridan.co.uk Sent: Thursday, November 25, 2010 3:34 AM To: Ron Piggott ; php-general@lists.php.net Subject: Re: [PHP] Fw: Spoofing user_agent You need to set it in the header request you make. Putting it in the script you're using as a spider with ini_set won't do anything because the Target site doesn't know anything about it. Thanks, Ash http://www.ashleysheridan.co.uk - Reply message - From: "Ron Piggott" Date: Thu, Nov 25, 2010 08:25 Subject: [PHP] Fw: Spoofing user_agent To: I have wrote a script to generate a sitemap of my web site. It crawls all of the site web pages. (About 30,000) I need help to spoof the user_agent variable so the stats program running in the background ( “AWSTATS” ) will treat the crawl as a bot, not browsing usage. The sitemap generator is a cron job. I tried the syntax: ini_set('user_agent', 'RonBot (http://www.theverseoftheday.info)/'/); This didn’t work. The browsing was attributed to the dedicated IP address. How do I get AWSTATS to access this, such as other entries under the “Robots/Spiders visitors” heading: Unknown robot (identified by 'bot*') I don’t mean any ill will by changing this setting. Thanks for the help. Ron The Verse of the Day “Encouragement from God’s Word” http://www.TheVerseOfTheDay.info -- Regards, Shreyas Agasthya
Re: [PHP] Fw: Spoofing user_agent
Is "User Agent" suppose to have a hyphen "-" ? Ron The Verse of the Day “Encouragement from God’s Word” http://www.TheVerseOfTheDay.info -Original Message- From: Richard Quadling Sent: Thursday, November 25, 2010 9:16 AM To: Deva Cc: Shreyas Agasthya ; Ron Piggott ; php-general@lists.php.net ; a...@ashleysheridan.co.uk Subject: Re: [PHP] Fw: Spoofing user_agent On 25 November 2010 11:32, Deva wrote: Use curl http://php.net/manual/en/book.curl.php On Thu, Nov 25, 2010 at 4:41 PM, Shreyas Agasthya wrote: I feel you should use more of the 4th method here as you are not trying to read the file but the header level (7th layer) information of the HTTP protocol. http://php.net/manual/en/function.file-get-contents.php --Shreyas On Thu, Nov 25, 2010 at 4:11 PM, Ron Piggott < ron.pigg...@actsministries.org > wrote: > Will the header pass with using file_get_contents , or should I be using > another command, and if so, which one? Ron > > > header('User Agent: RonBot (http://www.example.com)'); > $url = "http://www.example.com";; <http://www.example.com%22;> > > $input = file_get_contents($url); > > > > The Verse of the Day > “Encouragement from God’s Word” > http://www.TheVerseOfTheDay.info > > *From:* Shreyas Agasthya > *Sent:* Thursday, November 25, 2010 4:21 AM > *To:* Ron Piggott > *Cc:* php-general@lists.php.net ; a...@ashleysheridan.co.uk > *Subject:* Re: [PHP] Fw: Spoofing user_agent > > A standard HTTP Request headers is : User Agent (without the > underscore). > > --Shreyas > > On Thu, Nov 25, 2010 at 2:36 PM, Ron Piggott < > ron.pigg...@actsministries.org> wrote: > >> >> Is this what you are telling me to do: >> >> header('user_agent: RonBot (http://www.theverseoftheday.info)'); >> >> Ron >> >> The Verse of the Day >> “Encouragement from God’s Word” >> http://www.TheVerseOfTheDay.info >> >> From: a...@ashleysheridan.co.uk >> Sent: Thursday, November 25, 2010 3:34 AM >> To: Ron Piggott ; php-general@lists.php.net >> Subject: Re: [PHP] Fw: Spoofing user_agent >> >> You need to set it in the header request you make. Putting it in the >> script you're using as a spider with ini_set won't do anything because the >> Target site doesn't know anything about it. >> >> Thanks, >> Ash >> http://www.ashleysheridan.co.uk >> >> - Reply message - >> From: "Ron Piggott" >> Date: Thu, Nov 25, 2010 08:25 >> Subject: [PHP] Fw: Spoofing user_agent >> To: >> >> I have wrote a script to generate a sitemap of my web site. It crawls all >> of the site web pages. (About 30,000) >> >> I need help to spoof the user_agent variable so the stats program running >> in the background ( “AWSTATS” ) will treat the crawl as a bot, not browsing >> usage. >> >> The sitemap generator is a cron job. I tried the syntax: >> ini_set('user_agent', 'RonBot (http://www.theverseoftheday.info)/'/); >> >> This didn’t work. The browsing was attributed to the dedicated IP >> address. >> >> How do I get AWSTATS to access this, such as other entries under the >> “Robots/Spiders visitors” heading: >> Unknown robot (identified by 'bot*') >> >> I don’t mean any ill will by changing this setting. Thanks for the help. >> >> Ron >> >> The Verse of the Day >> “Encouragement from God’s Word” >> http://www.TheVerseOfTheDay.info >> >> > > > -- > Regards, > Shreyas Agasthya > -- Regards, Shreyas Agasthya -- :DJ It is no use using header(). This sets a header for the client, not the server of any file_get_contents() requests. I use stream_contexts. $s_Contents = file_get_contents( $s_URL, False, stream_context_create( array( 'http' => array( 'method' => 'GET', 'header' => "User-Agent: RonBot (http://www.example.com)\r\n" ), ) ) ); You can supply cookies, or anything else, with the request. Make sure you add a \r\n to each of the headers and just concatenate them. If you are doing this in a loop, then I'd recommend creating a default stream context and then the request would just be ... $s_Contents = file_get_contents($s_URL); As the default stream context would be applied. I had to use a default stream context to route all http requests through an NTLM authentication proxy server because PHP doesn't deal with NTLM authentication. See my user notes on http://docs.php.net/manual/en/function.stream-context-get-default.php. Don't bother with the link at the bottom of the user note- it's not live. Richard. -- Richard Quadling Twitter : EE : Zend @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Form Processing
I am unable to retrieve the value of $referral_1 from: $new_email = mysql_escape_string ( $_POST['referral_$i'] ); why? PHP while lopp to check if any of the fields were populated: $i=1; while ( $i <= 5 ) { $new_email = mysql_escape_string ( $_POST['referral_$i'] ); if ( strlen ( $new_email ) > 0 ) { } } The form itself: What am I doing wrong? Ron The Verse of the Day “Encouragement from God’s Word” http://www.TheVerseOfTheDay.info
Re: [PHP] Fw: Spoofing user_agent
My issue with the user agent is unresolved. I need to do more research to see how AWSTATS distinguishes between a robot crawling the site and a web page user and set the user-agent accordingly. The Verse of the Day “Encouragement from God’s Word” http://www.TheVerseOfTheDay.info From: Shreyas Agasthya Sent: Monday, November 29, 2010 1:35 AM To: Ron Piggott Cc: PHP General List Subject: Re: [PHP] Fw: Spoofing user_agent Ron, Can you let us know if this whole thing that you were trying to do worked? I see that very few actually bring a thread to a logical conclusion either by correcting the members here with the proposed fixes or letting the concerned set of people that they were right as rain. We should perhaps make this a practice and mandate so that the archives are utilized better. Correct me if I am wrong. Regards, Shreyas
Re: [PHP] Fw: Spoofing user_agent
The following solution works: I set my user-agent to: VerseOfTheDaySitemapRobot/1.0 (http://www.TheVerseOfTheDay.info) By doing: ini_set('user_agent', "VerseOfTheDaySitemapRobot/1.0 (http://www.TheVerseOfTheDay.info)"); When ran by a cron job this causes AWSTATS to treat the hits as: Unknown robot (identified by 'robot')9704+18284.82 MB30 Nov 2010 - 07:12 The part which tricked me is that if I run the site map generator PHP script using a user interface the hits on the site are credited to the Firefox (the browser I use) user-agent string. The following article discusses how to change browser user agents: http://www.walkernews.net/2007/07/05/how-to-change-user-agent-string/ Ron The Verse of the Day “Encouragement from God’s Word” http://www.TheVerseOfTheDay.info
[PHP] Variable Question
I am trying to assign variables from an array into variables. This is following a database query. Right now they are in an array: $row[‘word_1’] $row[‘word_2’] $row[‘word_3’] ... $row[‘word_25’] I am trying to use this while look to assign them to variables: $word_1 $word_2 $word_3 ... $word_25 This is the WHILE loop: $i = 1; while ( $i <= 25 ) { ${'word_'.$i} = stripslashes( eval ("echo $row['word_$i']") ); ++$i; } What is confusing me is I don’t know how to represent the array variable. The specific error message I am receiving is: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING Can anyone see what I have done wrong and help me correct it? Thank you. Ron Ron Piggott www.TheVerseOfTheDay.info
[PHP] function
I need to access a FUNCTION I programmed within a different FUNCTION. Are these able to be passed like a variable? Or are they able to become like a $_SESSION variable in nature? How am I able to do this? I am essentially programming: === function name( $flag1, $flag2 ) { # some PHP echo name_of_a_different_function( $flag1 , $flag2 ); } === The error I am receiving is “Call to undefined function name_of_a_different_function” Thanks, Ron Ron Piggott www.TheVerseOfTheDay.info
[PHP] Variable representation
I am trying to represent the variable: $row['Bible_knowledge_phrase_solver_game_question_topics_1'] Where the # 1 is replaced by a variable --- $i The following code executes without an error, but “Hello world” doesn’t show on the screen. What needs to change? Ron Ron Piggott www.TheVerseOfTheDay.info
Re: [PHP] Way to test if variable contains valid date
On Mon, Jul 2, 2012 at 2:54 PM, Ron Piggott wrote: Is there a way to test a variable contains a valid date - 4 digits for the year - 2 digits for the month (including leading 0) - 2 digits for the day (including leading 0) OR - a function? You may want to check out checkdate(): http://php.net/checkdate -- Network Infrastructure Manager http://www.php.net/ Hi Daniel I want to thank you, Daniel, for this help. - I was looking for an "isarray" type function www.TheVerseOfTheDay.info -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Array & unset()
I am wondering if there is a way to remove from an array where the value is 0 (“zero”) Array example: $total_points_awarded = array( 1 => 17, 3 => 14, 4 => 0, 5 => 1, 6 => 0 ); In this example I would like to remove element # 4 and # 6. The “key” ( 1,3,4,5,6 ) represents the member’s account #. It is an auto_increment value in a mySQL table The “value” ( 17,14,0,1,0 ) represents their score. The application for this is a list of the top users. If someone has 0 points I don’t want to include them. Any thoughts? Any help is appreciated. Ron Ron Piggott www.TheVerseOfTheDay.info
[PHP] Date manipulation
Is it possible for PHP to accept the following as a date: 04:11:22 Aug 21, 2011 PDT so I may output it as: gmdate(‘Y-m-d H:i:s’) - I want the time zone included Ron Ron Piggott www.TheVerseOfTheDay.info
[PHP] Variables with - in their name
I have made the following variable in a form: (I am referring the ) \r\n"; ?> It could be wrote: Only PHP is treating the hyphen as a minus sign --- which in turn is causing a syntax error. How do I retrieve the value of this variable and over come the “minus” sign that is really a hyphen? Ron Ron Piggott www.TheVerseOfTheDay.info
[PHP] Integer
In the following the “2.” means a moderator response and “25” is the account # of the moderator. How can I get the 25 by itself? - I want to drop the “2.” and remove all the zero’s Would it be best to turn this into a STRING? Any suggestions? Ron Piggott www.TheVerseOfTheDay.info
[PHP] Re: Integer
Thank you for the help. Very much appreciate it. Ron Piggott www.TheVerseOfTheDay.info -Original Message- From: Shawn McKenzie Sent: Saturday, February 02, 2013 1:43 PM To: php-general@lists.php.net ; Ron Piggott Subject: Re: Integer On 02/01/2013 10:40 PM, Ron Piggott wrote: In the following the “2.” means a moderator response and “25” is the account # of the moderator. How can I get the 25 by itself? - I want to drop the “2.” and remove all the zero’s Would it be best to turn this into a STRING? Any suggestions? Ron Piggott www.TheVerseOfTheDay.info Yeah needs to be a string: $author = "2.00025"; list($a, $b) = explode('.', $author); echo (int)$a . ' ' . (int)$b; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] include() Error
Good morning all: I have recently purchased a computer and am using it as a dedicated server. A friend helped me install PHP and configure. I am saying this because I wonder if using a newer version of PHP (compared to my commercial web host) may be the reasoning behind the error I am receiving. I created a function to generate a form submission key. - This created hidden variable for forms - This is also session variable With this function I have an ‘ include ‘ for the file containing the mySQL database, username and password. I know this file is being accessed because I added: === echo $mySQL_user; === following the login credentials. But when I remove this line from mySQL_user_login.inc.php and place within the function on the line following the include the "echo” returns nothing. === include("mySQL_user_login.inc.php"); echo $mySQL_user; === Can any of you tell me why this is happening? Ron Piggott www.TheVerseOfTheDay.info
[PHP] Resolving a PHP Notice Error
I am wanting to establish a default sort by preference when the user hasn’t specified one. I setup to test this with: But I am receiving a Notice error: Notice: Undefined variable: sort_by_preference in GIFI_codes.php on line 11- Line 11 is “if ( !is_set( $sort_by_preference ) ) {“What is the correct way to test this without triggering a Notice error?Ron Ron Piggott www.TheVerseOfTheDay.info
Re: [PHP] Parse question
On Jan 21, 2011, at 6:52 PM, Ron Piggott wrote: Would someone write me a syntax so all the web site addresses in $data turn into links $data = “Visit our web site http://www.site.com, http://www.secondsite.org and http://www.thirdsite.info.”; My desired results for what I am asking for help turn $data into: $output =“Visit our web site http://www.site.com”>http://www.site.com, http://www.secondsite.org”>http://www.secondsite.org and http://www.thirdsite.info”>http://www.thirdsite.info.”; Please make provision for .net web sites as well. Ron The Verse of the Day “Encouragement from God’s Word” http://www.TheVerseOfTheDay.info "Would someone write me a syntax" hummm... If you need help, we can do that, but if you want someone to write it for you, go here: http://www.google.com/#sclient=psy&hl=en&site=&source=hp&q=hire+freelance+PHP+web+developer&aq=f&aqi=&aql=&oq=&pbx=1&fp=d87fcfdb2e6b7745 === Now that I have seen some examples I will work on this and may ask a specific question tomorrow. I know how to program in PHP --- I am just not strong in the string manipulation commands. Thanks for these valuable links. Ron
[PHP] Manipulating variables
Is there a way to make this syntax: $checking_answer = $answer_reference_2; Equal to: $checking_answer = $answer_reference_ . ($i + 1); (where $i = 1) making $checking_answer take on the value of $answer_reference_2 ? I am trying to develop a web app quiz and I need to test the users answers. Ron The Verse of the Day “Encouragement from God’s Word” http://www.TheVerseOfTheDay.info
[PHP] Sorting an array
I need help to know how to sort the words / phrases in my array. Variable name: $words_used print_r( $words_used ); Current output: Array ( [187] => Sin [249] => Punished [98] => Sanctuary [596] => Sing [362] => Anointing Oil ) Desired result: Alphabetical sort: Array ( [362] => Anointing Oil [249] => Punished [98] => Sanctuary [187] => Sin [596] => Sing ) The #’s are the auto_increment value of the word in the mySQL database. The number is not representative of alphabetical order, but the order it was added to the database. Thank you for your assistance. Ron The Verse of the Day “Encouragement from God’s Word” http://www.TheVerseOfTheDay.info
[PHP] str_replace
I am trying to figure out a syntax that will replace each instance of % with a different letter chosen randomly from the string $puzzle_filler. $puzzle_filler is populated with the letters of the alphabet, roughly in the same ratio as they are used. This syntax replaces each instance of % with the same letter: $puzzle[$i] = str_replace ( "%" , ( substr ( $puzzle_filler , rand(1,98) , 1 ) ) , $puzzle[$i] ); Turning this: %ECARBME%TIPLUP%%%E%% Into: uECARBMEuTIPLUPuuuEuu Is there a way to tweak my str_replace so it will only do 1 % at a time, so a different replacement letter is selected? This is the syntax specific to choosing a replacement letter at random: substr ( $puzzle_filler , rand(1,98) , 1 ); Thanks for your help. Ron The Verse of the Day “Encouragement from God’s Word” http://www.TheVerseOfTheDay.info -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Custom function
Is it possible to write a function with an optional flag? What would the syntax look like? So far I have: function load_advertisement( $web_page_reference , $web_advertising_sizes_reference ) { Thanks Ron The Verse of the Day “Encouragement from God’s Word” http://www.TheVerseOfTheDay.info
Re: [PHP] Custom function
On Mon, May 2, 2011 at 3:16 PM, Ron Piggott wrote: Is it possible to write a function with an optional flag? What would the syntax look like? So far I have: function load_advertisement( $web_page_reference , $web_advertising_sizes_reference ) { Hi Ron: I'm not sure what you mean by "optional flag"? Do you mean an optional parameter? Richard Correct Richard. Ron
[PHP] Submit Using An Image Form Processing
I am writing a shopping cart using the PayPal API. Shopping cart works. Just adding additional functionality. >From the shopping cart contents I am trying to make it so the user may click >on a picture of a trash can to delete the item. I wrote the following line of >code: http://www.theverseoftheday.info/store-images/trash_can.png"; WIDTH="20" HEIGHT="20" style="float: right;boarder: 0;" alt="Remove Product From Shopping Cart" name="remove_product" value="1" /> But when I have do: echo $remove_product; I am not getting anything. Is there a correct way of passing a variable through an image? The value in this above example is the auto_increment value of the product. From this I could remove the item from the shopping cart. OR Is there a better way to pass a variable through a graphic? I am hoping for the shopping cart contents to be just 1 form where users will have several options (change quantities, delete specific items). I can’t use a hidden field. Thank you for your help. Ron The Verse of the Day “Encouragement from God’s Word” http://www.TheVerseOfTheDay.info
[PHP] Most popular word sorting
Is it possible in PHP to sort an array by most frequently occurring word / phrase, 2nd most frequently occurring, third, etc. An example array is: Array ( [1] => Parable [2] => Mustard [3] => Seed [4] => Parable [5] => Good [6] => Samaritan [7] => Parable [8] => Workers [9] => Vineyard [10] => Parable [11] => Lost [12] => Sheep [13] => Parable [14] => Lost [15] => Coin [16] => Parable [17] => Prodigal [18] => Parable [19] => Sower [20] => Parable [21] => Weeds [22] => Parable [23] => Hidden [24] => Treasure [25] => Parable [26] => Parable [27] => Wedding [28] => Banquet [29] => Parable [30] => Virgins [31] => Parable [32] => Bags [33] => Gold [34] => Parable [35] => Yeast ) The most popular word is “Parable”. I would like it to be the first result. Then the second most popular word is “Lost”. Then all the remaining words are only used once. Ron The Verse of the Day “Encouragement from God’s Word” http://www.TheVerseOfTheDay.info
[PHP] IF stream lining
Is there a way to stream line this: if ( ( $val <> "with" ) AND ( $val <> "from" ) ) { Ron The Verse of the Day “Encouragement from God’s Word” http://www.TheVerseOfTheDay.info
[PHP] PHP within XML?
I am trying to figure out if it is possible to have PHP work within an XML document. The application is tracking RSS subscribers IP addresses within the database. I have wrote functions so the PHP code required is below is minimal, after the XML declaration line. Prior to posting this question I tried to have the PHP at the very start, but that doesn’t work, the declaration line needs to be first. Right now the PHP is displayed as a comment. Thoughts anyone? Ron === RSS content starts here === Ron The Verse of the Day “Encouragement from God’s Word” http://www.TheVerseOfTheDay.info
[PHP] Opening Multiple Files
Hi Everyone I am trying to load an HTML book into mySQL. The book was distributed with each chapter being it’s own HTML file. The only way I know how to open a file is by specifying the file name. Such as: $myFile = "B01C001.htm"; $lines = file($myFile); foreach ($lines as $line_num => $theData) { Is there a way PHP will open each file in the directory ending in “.htm”, one file at a time, without me specifying the file name? When the file is open I need the FOREACH (above) to parse the content which ends with an “INSERT INTO” for a mySQL table. Thank you in advance for any help you are able to give me. Ron The Verse of the Day “Encouragement from God’s Word” http://www.TheVerseOfTheDay.info
[PHP] htmlentities
Is there a way to only change accented characters and not HTML (Example: ) The syntax echo htmlentities( stripslashes(mysql_result($whats_new_result,0,"message")) ) . "\r\n"; is doing everything (as I expect). I store breaking news within the database as HTML formatted text. I am trying to see if a work around is available? Do I need to do a variety of search / replace to convert the noted characters above back after htmlentities ? (I am just starting to get use to accented letters.) Thanks a lot for your help. Ron The Verse of the Day “Encouragement from God’s Word” http://www.TheVerseOfTheDay.info
[PHP] RSS Feed Accented Characters
I am trying to set up an RSS Feed in the Spanish language using a PHP cron job. I am unsure of how to deal with accented letters. An example: This syntax: " . htmlentities("El Versículo del Día") . "\r\n"; ?> Outputs: El Versículo del Día When I use an RSS Feed validator I receive the error message This feed does not validate. a.. line 24, column 20: XML parsing error: :24:20: undefined entity I suspect the “;” is the issue, although it is needed for the accented letters. If I don’t use htmlentities() the accented characters can’t be viewed, they become a “?” How should I proceed? Ron www.TheVerseOfTheDay.info
Re: [PHP] RSS Feed Accented Characters
-Original Message- From: Richard Quadling Sent: Friday, September 30, 2011 12:31 PM To: Ron Piggott Cc: php-general@lists.php.net Subject: Re: [PHP] RSS Feed Accented Characters On 30 September 2011 17:26, Ron Piggott wrote: I am trying to set up an RSS Feed in the Spanish language using a PHP cron job. I am unsure of how to deal with accented letters. An example: This syntax: $rss_content .= "" . htmlentities("El Versículo del Día") . "\r\n"; ?> Outputs: El Versículo del Día When I use an RSS Feed validator I receive the error message This feed does not validate. a.. line 24, column 20: XML parsing error: :24:20: undefined entity I suspect the “;” is the issue, although it is needed for the accented letters. If I don’t use htmlentities() the accented characters can’t be viewed, they become a “?” How should I proceed? Ron Make sure you have ... as the first line of the output. That tells the reader that the file is a UTF-8 encoded file. Also, if you ejecting HTTP headers, make sure that they say the encoding is UTF-8 and not a codepage. Go UTF-8 everywhere. -- Richard Quadling Twitter : EE : Zend : PHPDoc @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea Hi Richard: Having " " as the starting line didn't correct the problem. The RSS Feed is @ http://www.elversiculodeldia.info/peticiones-de-rezo-rss.xml There are a variety of errors related to accented characters while using a feed valuator http://validator.w3.org/feed/check.cgi?url=http%3A%2F%2Fwww.elversiculodeldia.info%2Fpeticiones-de-rezo-rss.xml - Also While viewing the feed in Firefox once the first accented character is displayed none of the rest of the feed is visible, except by right clicking and "view source" The RSS Feed content will be populated by a database query. The database columns are set to utf8_unicode_ci How should I proceed? Ron -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] RSS Feed Accented Characters
www.TheVerseOfTheDay.info -Original Message- From: Richard Quadling Sent: Friday, September 30, 2011 2:53 PM To: Ron Piggott Cc: php-general@lists.php.net Subject: Re: [PHP] RSS Feed Accented Characters On 30 September 2011 18:22, Ron Piggott wrote: -Original Message- From: Richard Quadling Sent: Friday, September 30, 2011 12:31 PM To: Ron Piggott Cc: php-general@lists.php.net Subject: Re: [PHP] RSS Feed Accented Characters On 30 September 2011 17:26, Ron Piggott wrote: I am trying to set up an RSS Feed in the Spanish language using a PHP cron job. I am unsure of how to deal with accented letters. An example: This syntax: " . htmlentities("El Versículo del Día") . "\r\n"; ?> Outputs: El Versículo del Día When I use an RSS Feed validator I receive the error message This feed does not validate. a.. line 24, column 20: XML parsing error: :24:20: undefined entity I suspect the “;” is the issue, although it is needed for the accented letters. If I don’t use htmlentities() the accented characters can’t be viewed, they become a “?” How should I proceed? Ron Make sure you have ... as the first line of the output. That tells the reader that the file is a UTF-8 encoded file. Also, if you ejecting HTTP headers, make sure that they say the encoding is UTF-8 and not a codepage. Go UTF-8 everywhere. -- Richard Quadling Twitter : EE : Zend : PHPDoc @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea Hi Richard: Having " " as the starting line didn't correct the problem. The RSS Feed is @ http://www.elversiculodeldia.info/peticiones-de-rezo-rss.xml There are a variety of errors related to accented characters while using a feed valuator http://validator.w3.org/feed/check.cgi?url=http%3A%2F%2Fwww.elversiculodeldia.info%2Fpeticiones-de-rezo-rss.xml - Also While viewing the feed in Firefox once the first accented character is displayed none of the rest of the feed is visible, except by right clicking and "view source" The RSS Feed content will be populated by a database query. The database columns are set to utf8_unicode_ci How should I proceed? Ron The byte sequence that is being received is just 0xED. php -r "file_put_contents('a.rss', file_get_contents('http://www.elversiculodeldia.info/peticiones-de-rezo-rss.xml'));" This is NOT UTF-8 encoded data, but is ISO-8859-1 Latin-1 (most likely). So as I see it you have 1 choice. Either use as the XML tag or convert the encoded data to UTF-8. It also means that the data in the sql server is NOT UTF-8 and will need to be converted also. I would recommend doing that first. That will mean reading the data as ISO-8859-1 and converting it to UTF-8 and then saving it again. I'd also be looking at the app that inputs the data into the DB initially. To convert the text, here are 2 examples. I'm sure there are more ways. $iso_text = 'El Versículo del Día: Pray For Others: Incoming Prayer Requests'; $utf_8_text = utf8_encode($iso_text); var_dump($iso_text, $utf_8_text); $utf_8_text = iconv('ISO-8859-1', 'UTF-8', $iso_text); var_dump($iso_text, $utf_8_text); ?> outputs ... string(63) "El Vers퀀culo del D퀀a: Pray For Others: Incoming Prayer Requests" string(65) "El Versículo del Día: Pray For Others: Incoming Prayer Requests" string(63) "El Vers퀀culo del D퀀a: Pray For Others: Incoming Prayer Requests" string(65) "El Versículo del Día: Pray For Others: Incoming Prayer Requests" notice that the correct strings are 2 bytes longer? The í is encoded as 0xC3AD or U+00ED. -- Richard Quadling Twitter : EE : Zend : PHPDoc @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea Richard I was unaware of the utf8_encode command. Thank you very much --- this now works. Now I may continue with the translation into Spanish. Ron -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Variable question
If $correct_answer has a value of 3 what is the correct syntax needed to use echo to display the value of $trivia_answer_3? I know this is incorrect, but along the lines of what I am wanting to do: echo $trivia_answer_$correct_answer; $trivia_answer_1 = “1,000”; $trivia_answer_2 = “1,250”; $trivia_answer_3 = “2,500”; $trivia_answer_4 = “5,000”; Ron www.TheVerseOfTheDay.info
[PHP] Pipe To A Program
I am looking at CPanel’s “E-Mail filtering” option “Pipe To A Program” http://docs.cpanel.net/twiki/bin/view/AllDocumentation/CpanelDocs/FilterOptions The goal I am working towards is saving the contents of an incoming e-mail address into a mySQL table. I am thinking of trying to program a customer contact center application. Does anyone know what variable the e-mail message is assigned within the context of “Pipe To A Program”? Is there a way to find out? I can’t figure this out. What I have tried so far is below: === #!/usr/local/bin/php -q $val) { $$key = $val; $email_body .= "KEY: " . $key . "\r\n"; $email_body .= "VAL: " . $val . "\r\n"; $email_body .= "\r\n"; } mail( user@domain , "Test Pipe To Program" , $email_body ); === The mail command works, but the e-mail message body is empty. I am at a loss of how to proceed. Ron
Re: [PHP] Pipe To A Program
I used your code and it still didn't work. Would you show me what you put in for your Pipe To A Program settings? What I used is: Rules: "To" "Contains" customer service e-mail address "Action" /usr/local/bin/php /path/to/email_to_ticket_gateway.php - I know the rule is working because I receive an empty e-mail, just not passing the e-mail content Ron Piggott www.TheVerseOfTheDay.info -Original Message- From: tamouse mailing lists Sent: Saturday, November 12, 2011 4:04 AM To: Ron Piggott Cc: php-general@lists.php.net Subject: Re: [PHP] Pipe To A Program On Sat, Nov 12, 2011 at 1:38 AM, Ron Piggott wrote: Does anyone know what variable the e-mail message is assigned within the context of “Pipe To A Program”? Is there a way to find out? I can’t figure this out. What I have tried so far is below: === #!/usr/local/bin/php -q $val) { $$key = $val; $email_body .= "KEY: " . $key . "\r\n"; $email_body .= "VAL: " . $val . "\r\n"; $email_body .= "\r\n"; } mail( user@domain , "Test Pipe To Program" , $email_body ); === The mail command works, but the e-mail message body is empty. I am at a loss of how to proceed. Ron I'm not sure what's going on with your program, exactly. Here's what I tried: start script<< $val) { $$key = $val; // do not know what this is supposed to do here... $email_body .= wordwrap("KEY: " . $key . "\n",70,"\n"); $email_body .= wordwrap("VAL: " . $val . "\n",70,"\n"); $email_body .= "\n"; } print_r($email_body); mail( 'tamara@localhost' , "Test Pipe To Program" , $email_body ); end script<< (Note: according to http://us3.php.net/manual/en/function.mail.php: "Each line should be separated with a LF (\n). Lines should not be larger than 70 characters." Which is why I added the wordwrap on each line and terminated the lines with "\n" instead of "\r\n".) Calling the script, print_r showed the string as expected: start output<< tamara@caesar:~/$ curl 'http://localhost/~tamara/testmail.php?a=1&b=2&c=3' KEY: a VAL: 1 KEY: b VAL: 2 KEY: c VAL: 3 end output<< And the email message showed up in my inbox: tamara@caesar:~/$ from Test Pipe To Program And the contents of the email are: start email<< Return-Path: Delivery-Date: Sat Nov 12 02:54:13 2011 Envelope-to: Return-path: Received: from www-data by caesar with local (masqmail 0.2.27) id 1RP9Lp-0oD-00 for ; Sat, 12 Nov 2011 02:54:13 -0600 To: tamara@localhost Subject: Test Pipe To Program X-PHP-Originating-Script: 1000:testmail.php From: Date: Sat, 12 Nov 2011 02:54:13 -0600 Message-ID: <1RP9Lp-0oD-00@caesar> KEY: a VAL: 1 KEY: b VAL: 2 KEY: c VAL: 3 end email<< -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Parsing the From field
I am unsure of how to parse first name, last name and e-mail address from the 'From:' field of an e-mail. What I am struggling with is if the name has more than two words - Such as the last name being multiple words - A name a business or department is given instead of a personal name - If the person has included their middle name, middle initial or degrees (“Dr.”) - If last name has multiple words Also the formatting of the from field changes in various e-mail programs: From: Ron Piggott From: "Ron Piggott" From: ron.pigg...@actsministries.org From: If there is more than 2 words for the name I would like them to be assigned to the last name. Ron Ron Piggott www.TheVerseOfTheDay.info
Re: [PHP] Parsing the From field
My web site is used by people from approximately of 90 countries. - I will use just "name" instead of first name / last name. - e-mail address Ron Piggott www.TheVerseOfTheDay.info -Original Message- From: Alain Williams Sent: Saturday, November 19, 2011 11:29 AM To: Ron Piggott Cc: php-general@lists.php.net Subject: Re: [PHP] Parsing the From field On Sat, Nov 19, 2011 at 11:23:59AM -0500, Ron Piggott wrote: I am unsure of how to parse first name, last name and e-mail address from the 'From:' field of an e-mail. What I am struggling with is if the name has more than two words - Such as the last name being multiple words - A name a business or department is given instead of a personal name - If the person has included their middle name, middle initial or degrees (“Dr.”) - If last name has multiple words Also the formatting of the from field changes in various e-mail programs: From: Ron Piggott From: "Ron Piggott" From: ron.pigg...@actsministries.org From: If there is more than 2 words for the name I would like them to be assigned to the last name. You can make no such assumption, different people/companies/... do it in different ways. If you really want to have fun look at the different 'norms' from different countries. -- Alain Williams Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT Lecturer. +44 (0) 787 668 0256 http://www.phcomp.co.uk/ Parliament Hill Computers Ltd. Registration Information: http://www.phcomp.co.uk/contact.php #include -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Variable representation
Hi Everyone: I am assigning the value of 4 images to variables following a database query: $image_1 = stripslashes( $row['image_1'] ); $image_2 = stripslashes( $row['image_2'] ); $image_3 = stripslashes( $row['image_3'] ); $image_4 = stripslashes( $row['image_4'] ); What I need help with is how to represent the variable using $i for the number portion in the following WHILE loop. I am not sure of how to correctly do it. I am referring to: $image_{$i} === $i = 1; while ( $i <= 4 ) { if ( trim( $image_{$i} ) <> "" ) { echo "http://www.theverseoftheday.info/store-images/"; . $image_{$i} . "\" title=\"Image " . $i . "\">Image " . $i . "\r\n"; } ++$i; } === How do I substitute $i for the # so I may use a WHILE loop to display the images? (Not all 4 variables have an image.) Ron Piggott www.TheVerseOfTheDay.info
[PHP] text to HTML
Is there a PHP command that turns text into HTML? EXAMPLE: "before" Hi. How are you doing? "after" Hi. How are you doing?
[PHP] Uploading a file through PHP form
How do you upload a file using PHP? Also what is the web page which describes the procedure on php.net ? Thanks, Ron -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] " using the mail() command
When I use the mail($email, $subject, $message, $headers); command I assign the value of $message as follows: $boundary = md5(uniqid(time())); $message = " --$boundary Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit blah --$boundary Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Blah --$boundary-- "; I would like to be able to include a " in my message body --- both the HTML and text version --- how can I accomplish this? (I use a " to assign the value of $subject). I have been able to get \" to work --- but \" shows when reading the e-mail, not just the ". Thanks for your help Ron -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] " using the mail() command
Thanks for the new command and help. It worked! Ron On Sat, 2008-02-02 at 19:46 -0500, Greg Bowser wrote: > First off, I would use heredoc syntax so you don't need to escape the > quotes: > > $message = << blah blah blah > $your $stuff > $here > " > ' > \ blah blah > > EOF; > > Also, since you're using text/html as your content-type, you should > probably be using " instead of ". > > --Greg -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Resetting a session variable
What is the command to reset a session variable --- essentially deleting all of the values it contains? Ron -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] strtotime
I am trying to calculate what was the date 18 months ago. When I give the command: $18_months_ago = strtotime("-18 months"); It comes back with: Parse error: parse error, unexpected T_LNUMBER, expecting T_VARIABLE How would you calculate 18 months ago from today? Ron -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: strtotime
I see I broke a rule. The variable can't start with a number. Still strtotime doesn't work with -18 months How would you handle this? Ron On Sun, 2008-02-10 at 06:46 -0500, Ron Piggott wrote: > I am trying to calculate what was the date 18 months ago. When I give > the command: > > $18_months_ago = strtotime("-18 months"); > > It comes back with: > > Parse error: parse error, unexpected T_LNUMBER, expecting T_VARIABLE > > How would you calculate 18 months ago from today? > > Ron -- [EMAIL PROTECTED] www.actsministrieschristianevangelism.org Acts Ministries Christian Evangelism "Where People Matter" 12 Burton Street Belleville, Ontario, Canada K8P 1E6 In Belleville Phone : (613) 967-0032 In North America Call Toll Free : (866) ACTS-MIN Fax: (613) 967-9963 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] strtotime
I figured out what went wrong. Ron -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] strtotime
The date value I was assigning was for a mySQL query ... a date range query. I was running my query when I hadn't assigned a date to the other date range variable. I didn't realized I hadn't copied my DATE() syntax to this area of my code. Ron On Sun, 2008-02-10 at 18:22 +0100, Floor Terra wrote: > On 2/10/08, Ron Piggott <[EMAIL PROTECTED]> wrote: > > I figured out what went wrong. Ron > > > Care to share it with us? > > Floor -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP variable values
What is the command which shows the value of all the variables in memory? Ron -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Ajax, an HTML form being saved in mySQL
I am trying to bring my programming skills together ... but I have hit a road block. I am writing my own ledger (accounting) software. I am needing help to pass 2 variables generated by Ajax through my form to be saved in a mySQL table. A sample of what ledger_select_account.js outputs is as follows --- the PHP script it accesses queries a table and then echo's this to the screen. PayPal (REF: 1) Receiver General (REF: 3) TD Canada Trust (REF: 2) The source code for ledger_select_account.js is: var xmlHttp function showCustomer(str) { xmlHttp=GetXmlHttpObject(); if (xmlHttp==null) { alert ("Your browser does not support AJAX!"); return; } var url="ledger_account_details.php"; url=url+"?account_source="+str; url=url+"&sid="+Math.random(); xmlHttp.onreadystatechange=stateChanged; xmlHttp.open("GET",url,true); xmlHttp.send(null); } function stateChanged () { if (xmlHttp.readyState == 4) { document.getElementById("txtHint").innerHTML=xmlHttp.responseText; } else { //alert(xmlHttp.readyState) } } function GetXmlHttpObject() { var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; } A sample of what ledger_select_gifi.js outputs is as follows --- the PHP script it accesses queries a table and then echo's this to the screen. Bank Charges (8715: Bank Charges) Benevolent Fund (9270: Other Expenses) Computer Equipment / Software (1774: Computer Equipment / Software) Office Expenses (8811: Office stationery and supplies) Our Advertising Campaign Expenses (8521: Advertising) Photocopying (8810: Photocopying) Postage (9275: Delivery, Freight and Express) Telephone Expenses (9225: Telephone and Communications) Web Site Hosting (9152: Internet) The source code for ledger_select_gifi.js is: var xmlHttp2 function showGIFI(str) { xmlHttp2=GetXmlHttpObject(); if (xmlHttp2==null) { alert ("Your browser does not support AJAX!"); return; } var url="ledger_gifi_details.php"; url=url+"?transaction_type="+str; url=url+"&sid="+Math.random(); xmlHttp2.onreadystatechange=stateChanged2; xmlHttp2.open("GET",url,true); xmlHttp2.send(null); } function stateChanged2 () { if (xmlHttp2.readyState == 4) { document.getElementById("txtGIFI").innerHTML=xmlHttp2.responseText; } else { //alert(xmlHttp.readyState) } } function GetXmlHttpObject() { var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; } The form which submits the ledger entry is this: New Ledger Entry Name Record Source: MAKE YOUR SELECTION Member Services Account Ledger Account Supplier Advertiser Account Account Reference: Account holder information will be listed here. Transaction Type: MAKE YOUR SELECTION Donation Expense Income PayPal Funds Transfer Payroll GIFI Reference: GIFI information will be listed here. Transaction Date (-MM-DD): Foreign Currency Received: $ Foreign Currency Identifier: U.S. Funds Foreign Currency Exchange Rate: $ Dollar Value: $ Bank Account Reference: PayPal TD Canada Trust Cheque Reference: Bank Account Balance: $ Notepad: The form processes and goes into this INSERT INTO statement: @mysql_select_db($database) or die( "Unable to select database"); mysql_query("INSERT INTO `ledger_entry` (`reference` ,`account_source` ,`account_reference` ,`transaction_type` ,`gifi_reference` ,`transaction_date` ,`foreign_currency_dollar_value` ,`foreign_currency_identifier` ,`foreign_currency_exchange_rate` ,`dollar_value` ,`bank_account_reference` ,`cheque_reference` ,`bank_account_balance` ,`created_by` ,`notepad` ,`entry_date`)VALUES (NULL , '$account_source', '$account_reference', '$transaction_type', '$gifi_reference', '$transaction_date', '$foreign_currency_dollar_value', '$foreign_currency_identifier', '$foreign_currency_exchange_rate', '$dollar_value', '$bank_account_reference', '$cheque_reference', '$bank_account_balance', '$record', '$notepad', '$entry_date');"); $created_ledger_record_reference = mysql_insert_id(); mysql_close(); All the variables, but the two ajax ones ( $account_reference & $gifi_reference ) make it into the table. I initially just had 1 ajax set up ( ledger_select_account.js ) . When there was just the one the value of $account_reference was inserted into the ledger_entry table. At that point I was still displaying all of the possible GIFI codes which could be selected. I am now only wanting to display the GIFI codes which are relevant. I am
[PHP] Calculating dates
Is there an easy way to calculate the number of days between two dates? Example: 2008-02-27 - 2007-12-03 = 86 days The dates will be in the format above -MM-DD Ron -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Calculating dates
Thanks. That's a nifty way of doing this. Ron On Fri, 2008-02-29 at 22:08 -0800, Jim Lucas wrote: > Ron Piggott wrote: > > Is there an easy way to calculate the number of days between two dates? > > > > Example: 2008-02-27 - 2007-12-03 = 86 days > > > > The dates will be in the format above -MM-DD > > > > Ron > > > > This should do the trick > > > $date1 = '2008-02-27'; > $date2 = '2007-12-03'; > > $udate1 = strtotime($date1); > $udate2 = strtotime($date2); > > $factor = 86400; > > > $difference = (($udate1 - $udate2) / $factor); > > echo "The difference is {$difference} days"; > > > Jim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Date math
I have this math equation this list helped me generate a few weeks ago. The purpose is to calculate how many days have passed between 2 dates. Right now my output ($difference) is 93.958333 days. I am finding this a little weird. Does anyone see anything wrong with the way this is calculated: $date1 = strtotime($date1); (March 21st 2008) $date2 = strtotime($date2); (December 18th 2007) echo $date1 => 1206072000 echo $date2 => 1197954000 #86400 is 60 seconds x 60 minutes x 24 hours (in other words 1 days worth of seconds) $factor = 86400; $difference = (($date1 - $date2) / $factor); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date math
Could someone then help me modify the PHP script so I won't have this timezone issue? I don't understand from looking at the date page on the PHP web site the change(s) I need to make. Thanks, Ron Ron Piggott wrote: > > I have this math equation this list helped me generate a few weeks ago. > > The purpose is to calculate how many days have passed between 2 dates. > > > > Right now my output ($difference) is 93.958333 days. > > > > I am finding this a little weird. Does anyone see anything wrong with > > the way this is calculated: > > > > $date1 = strtotime($date1); (March 21st 2008) > > $date2 = strtotime($date2); (December 18th 2007) > > > > echo $date1 => 1206072000 > > echo $date2 => 1197954000 > > > > #86400 is 60 seconds x 60 minutes x 24 hours (in other words 1 days > > worth of seconds) > > > > $factor = 86400; > > > > $difference = (($date1 - $date2) / $factor); > > > > > > > > As Casey suggested, it is a timestamp issue. > > Checkout my test script. > > http://www.cmsws.com/examples/php/testscripts/[EMAIL PROTECTED]/0001.php > > > $date1 = strtotime('March 21st 2008'); //(March 21st 2008) > echo "date1 = {$date1}\n"; > > $date2 = strtotime('December 18th 2007'); //(December 18th 2007) > echo "date2 = {$date2}\n"; > > $date1 = 1206072000; > echo date('c', $date1)."\n"; > > $date2 = 1197954000; > > echo date('c', $date2)."\n"; > > > #86400 is 60 seconds x 60 minutes x 24 hours (in other words 1 days worth of > seconds) > > $factor = 86400; > > $difference = (($date1 - $date2) / $factor); > > echo $difference."\n"; > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Month with leading zeros
I am wanting to change echo " 'January', '2' => 'February', '3' => 'March', '4' => 'April', '5' => 'May', '6' => 'June', '7' => 'July', '8' => 'August', '9' => 'September', '10' => 'October', '11' => 'November', '12' => 'December'); $current_month = DATE("n"); echo "\r\n"; foreach (range(1, 12) as $month) { echo "" . $months[$month] . "\r\n"; } ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Help with a foreach statement
I am writing a shopping cart. Products assigned in the following fashion: $_SESSION['selection'][$product]=$quantity; I am wanting to display the list of products in the shopping cart in a list for the user to see as they continue shopping. I put the SESSION variable into $cart $cart = $_SESSION['selection']; then I start the foreach and this is where I get messed up. I am trying to ECHO the following syntax to the screen with each selected product: The part I need help with is to write the foreach loop to give me $product (so I may query the database to find out the product name) and the $quantity (so I may show the user what they are purchasing). The part that is messing me up is that this is an array. My ECHO statement should look like this: echo "" . $product_name . " - " . $quantity . "\r\n"; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Date
If $expiry_date = "2007-10-17"; How do I add 7 days to this? I know the strtotime("+7 days"); command, but don't know how to make it work with a date that isn't today. (Please respond directly to my e-mail address) Ron
[PHP] Date
How do I break $start_date into 3 variables --- 4 digit year, 2 digit month and 2 digit day? $start_year = ; $start_month = ; $start_day = ;