473,466 Members | 1,439 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How can I get a variable containing digits to display?

110 New Member
I am haviing a problem getting fields from a datatable to display if they contain digits, like 5.00 or $25.00. My php page will display any other variables without any problems. How can I get these fields that contain digits to display?
Jan 27 '10 #1
9 1898
kovik
1,044 Recognized Expert Top Contributor
What do you mean? There is no display at all? Show us some code.
Jan 27 '10 #2
andersond
110 New Member
The field I am interested in is called "totalMonthlyAmount," which contains the value "$131.00."

Expand|Select|Wrap|Line Numbers
  1.  
  2. $paymentamount = $_REQUEST['totalMonthlyAmount'];
  3.  
  4.  
  5.  $subject = "RE: $insured - submission received:";
  6.  
  7.  $body = "United Brokers has received data from the Occupational Accident application you submitted on <b><u>$insured</u></b> asking that it be bound.  
  8.  Your underwriter, $underwriter, will review it and contact you in one business day or less if more information is needed.  Then,
  9.  when your signed application and Agent Disclaimer, along with the first payment of $paymentamount, have been received your underwriter will forward them to the carrier 
  10.  and send you a binder.<br><br>It is always a pleasure to do business with you.<br><br>
  11.  
  12.  
United Brokers";
Jan 27 '10 #3
kovik
1,044 Recognized Expert Top Contributor
You do realize that the "$_REQUEST" superglobal array and the database are two different things, right? Secondly, try using print_r on $_REQUEST to see what data is in it.

Personally, I recommend against using $_REQUEST. $_REQUEST allows certain request methods to overwrite others, giving unpredictable results.
Jan 27 '10 #4
andersond
110 New Member
Yes. I do realize that the fields from the database have been sent in an associative array. And, I have no problem displaying field values that do not start with a digit or a "$". Here is the entire file;
Expand|Select|Wrap|Line Numbers
  1. $fromname = $_REQUEST['underwriter'];
  2.  $underwriter = $_REQUEST['underwriter'];
  3.  $underwriter1email = $_REQUEST['underwriterEmail'];
  4.  $agent = $_REQUEST['Agent'];
  5.  $producer = $_REQUEST['Producer'];
  6.  $insured = $_REQUEST['ownerOperatorName'];
  7.  $paymentamount = $_GET['totalMonthlyAmount'];
  8.  
  9.  
  10.  $subject1 = "RE: $insured - submission received:";
  11.  $subject2 = "RE: Occ Acc submission on $insured:";
  12.  
  13.  $body1 = "United Brokers has received data from the Occupational Accident application you submitted on <b><u>$insured</u></b> asking that it be bound.  
  14.  Your underwriter, $underwriter, will review it and contact you in one business day or less if more information is needed.  Then,
  15.  when your signed application and Agent Disclaimer, along with the first payment of $paymentamount, have been received your underwriter will forward them to the carrier 
  16.  and send you a binder.<br><br>It is always a pleasure to do business with you.<br><br>
  17.  United Brokers";
  18.  
  19.  $body2 = "$producer, of $agent, has submitted an Occ Acc application on <b><u>$insured</u></b> and requested that it be bound.  
  20.  Please review the application and contact the producer in one business day or less if more information is needed.  Otherwise be prepared to 
  21.  submit it to the insurance carrier when the signed application and Agent Disclaimer, along with $paymentamount, have been received.";
  22.  
  23.   $eol="\r\n";
  24.   $attachments=false;
  25.   $mime_boundary=md5(time());
  26.  
  27.   # Common Headers
  28.   $headers .= "From: ".$fromname."<".$fromaddress.">".$eol;
  29.   $headers .= "Reply-To: ".$fromname."<".$fromaddress.">".$eol;
  30.   $headers .= "Return-Path: ".$fromname."<".$fromaddress.">".$eol;    // these two to set reply address
  31.   $headers .= "Message-ID: <".time()."-".$fromaddress.">".$eol;
  32.   $headers .= "X-Mailer: PHP v".phpversion().$eol;          // These two to help avoid spam-filters
  33.  
  34.   # Boundry for marking the split & Multitype Headers
  35.   $headers .= 'MIME-Version: 1.0'.$eol.$eol;
  36.   $headers .= "Content-Type: multipart/mixed; boundary=\"".$mime_boundary."\"".$eol.$eol;
  37.  
  38.   # Open the first part of the mail email1
  39.   $msg1 = "--".$mime_boundary.$eol;
  40.  
  41.   $htmlalt_mime_boundary = $mime_boundary."_htmlalt"; //we must define a different MIME boundary for this section
  42.   # Setup for text OR html -
  43.   $msg1 .= "Content-Type: multipart/alternative; boundary=\"".$htmlalt_mime_boundary."\"".$eol.$eol;
  44.  
  45.   # Text Version
  46.   $msg1 .= "--".$htmlalt_mime_boundary.$eol;
  47.   $msg1 .= "Content-Type: text/plain; charset=iso-8859-1".$eol;
  48.   $msg1 .= "Content-Transfer-Encoding: 8bit".$eol.$eol;
  49.   $msg1 .= strip_tags(str_replace("<br>", "\n", substr($body, (strpos($body, "<body>")+6)))).$eol.$eol;
  50.  
  51.   # HTML Version
  52.   $msg1 .= "--".$htmlalt_mime_boundary.$eol;
  53.   $msg1 .= "Content-Type: text/html; charset=iso-8859-1".$eol;
  54.   $msg1 .= "Content-Transfer-Encoding: 8bit".$eol.$eol;
  55.   $msg1 .= $body1.$eol.$eol;
  56.  
  57.   //close the html/plain text alternate portion
  58.   $msg1 .= "--".$htmlalt_mime_boundary."--".$eol.$eol;
  59.  
  60.   # Open the first part of the mail email2
  61.   $msg2 = "--".$mime_boundary.$eol;
  62.  
  63.   $htmlalt_mime_boundary = $mime_boundary."_htmlalt"; //we must define a different MIME boundary for this section
  64.   # Setup for text OR html -
  65.   $msg2 .= "Content-Type: multipart/alternative; boundary=\"".$htmlalt_mime_boundary."\"".$eol.$eol;
  66.  
  67.   # Text Version
  68.   $msg2 .= "--".$htmlalt_mime_boundary.$eol;
  69.   $msg2 .= "Content-Type: text/plain; charset=iso-8859-1".$eol;
  70.   $msg2 .= "Content-Transfer-Encoding: 8bit".$eol.$eol;
  71.   $msg2 .= strip_tags(str_replace("<br>", "\n", substr($body, (strpos($body, "<body>")+6)))).$eol.$eol;
  72.  
  73.   # HTML Version
  74.   $msg2 .= "--".$htmlalt_mime_boundary.$eol;
  75.   $msg2 .= "Content-Type: text/html; charset=iso-8859-1".$eol;
  76.   $msg2 .= "Content-Transfer-Encoding: 8bit".$eol.$eol;
  77.   $msg2 .= $body2.$eol.$eol;
  78.  
  79.   //close the html/plain text alternate portion
  80.   $msg2 .= "--".$htmlalt_mime_boundary."--".$eol.$eol;
  81.   if ($attachments !== false)
  82.   {
  83.     for($i=0; $i < count($attachments); $i++)
  84.     {
  85.       if (is_file($attachments[$i]["file"]))
  86.       {   
  87.         # File for Attachment
  88.         $file_name = substr($attachments[$i]["file"], (strrpos($attachments[$i]["file"], "/")+1));
  89.  
  90.         $handle=fopen($attachments[$i]["file"], 'rb');
  91.         $f_contents=fread($handle, filesize($attachments[$i]["file"]));
  92.         $f_contents=chunk_split(base64_encode($f_contents));    //Encode The Data For Transition using base64_encode();
  93.         $f_type=filetype($attachments[$i]["file"]);
  94.         fclose($handle);
  95.  
  96.         # Attachment email1
  97.         $msg1 .= "--".$mime_boundary.$eol;
  98.         $msg1 .= "Content-Type: ".$attachments[$i]["content_type"]."; name=\"".$file_name."\"".$eol;  // sometimes i have to send MS Word, use 'msword' instead of 'pdf'
  99.         $msg1 .= "Content-Transfer-Encoding: base64".$eol;
  100.         $msg1 .= "Content-Description: ".$file_name.$eol;
  101.         $msg1 .= "Content-Disposition: attachment; filename=\"".$file_name."\"".$eol.$eol; // !! This line needs TWO end of lines !! IMPORTANT !!
  102.         $msg1 .= $f_contents.$eol.$eol;
  103.         # Attachment email2
  104.         $msg2 .= "--".$mime_boundary.$eol;
  105.         $msg2 .= "Content-Type: ".$attachments[$i]["content_type"]."; name=\"".$file_name."\"".$eol;  // sometimes i have to send MS Word, use 'msword' instead of 'pdf'
  106.         $msg2 .= "Content-Transfer-Encoding: base64".$eol;
  107.         $msg2 .= "Content-Description: ".$file_name.$eol;
  108.         $msg2 .= "Content-Disposition: attachment; filename=\"".$file_name."\"".$eol.$eol; // !! This line needs TWO end of lines !! IMPORTANT !!
  109.         $msg2 .= $f_contents.$eol.$eol;
  110.       }
  111.     }
  112.   }
  113.  
  114.   # Finished
  115.   $msg1 .= "--".$mime_boundary."--".$eol.$eol;  // finish with two eol's for better security. see Injection.
  116.   $msg2 .= "--".$mime_boundary."--".$eol.$eol;
  117.  
  118.   # SEND THE EMAIL
  119.   ini_set(sendmail_from,$fromaddress);  // the INI lines are to force the From Address to be used !
  120.   $mail_sent1 = mail($to1, $subject1, $msg1, $headers);
  121.   sleep(1);
  122.   $mail_sent2 = mail($to2, $subject2, $msg2, $headers);
  123.  
  124.  
  125.   ini_restore(sendmail_from);
  126.  
  127.   ?>
  128.  
Jan 27 '10 #5
kovik
1,044 Recognized Expert Top Contributor
Again, print out the raw information using print_r and tell me what you get.
Jan 27 '10 #6
andersond
110 New Member
I am very new to PHP so I have no idea how to do what you are asking.
Jan 27 '10 #7
kovik
1,044 Recognized Expert Top Contributor
print_r() is a function. I linked it in an earlier post for you. It outputs the contents of an array.

Expand|Select|Wrap|Line Numbers
  1. print_r($_REQUEST);
Jan 27 '10 #8
andersond
110 New Member
Here is my code:

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. print_r($_REQUEST['underwriter']);            //Dida Taylor
  3. print_r($_REQUEST['ProducerEmail']);        //andersond@ubinc.com
  4. print_r($_REQUEST['underwriterEmail']);        //didat@ubinc.com
  5. print_r($_REQUEST['monthlyPremium']);        //$125.00
  6. print_r($_REQUEST['nonOccAccPremium']);        //5.00
  7. print_r($_REQUEST['associationFee']);        //5.00
  8. print_r($_REQUEST['totalMonthlyAmount']);     //$135.00
  9. print_r($_REQUEST['effectiveDate']);        //02/01/2010
  10.  
  11. ?>
  12.  
and this is the resulting string:

Dida Taylorandersond@ubinc.comdidat@ubinc.com5.0002/01/2010
Jan 27 '10 #9
andersond
110 New Member
Thank you for your help and your patience. Using your suggestion (print_r) I figured out the problem. Without your help I would have pulled out my hair.
Jan 27 '10 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: David Casey | last post by:
I'm working on a program for my C++ class and have it all written and working except for one part. I need to compare two numeric variables to determine decimal accuracy between them. For example:...
6
by: christopher.secord | last post by:
I have a table containing typed log entries. One log entry is supposed to be created every twelve hours, but sometimes there are gaps. I need to create a report showing the time of entry, and the...
5
by: greenflame | last post by:
How can I tell if a variable. I want ot tell whether two variables are: 1. Both numbers. Just a number. same as the number object in javascript. 2. Either one is a string containing a number....
11
by: Joriveek | last post by:
I have a float variable like 123456789 I want to right truncate this and only display say only 8 right most values all the time or otherwise filled by zeros if it is less than 8 digits, do you...
13
by: Kosio | last post by:
Hello, I know of a way to extract digits from a number using the %10 and divide by 10. But I am wondering if there is an algorithm out there that does not use a divide by 10 feature. The...
2
by: Joe Molloy | last post by:
Hi, This isn't a mission critical question but I thought I'dl throw it out there for your feedback as it's a bit curious. I have developed a shopping cart for an application I'm working on...
20
by: MLH | last post by:
120 MyString = "How many copies of each letter do you need?" 150 MyVariant = InputBox(MyString, "How Many?", "3") If MyVariant = "2" Then MsgBox "MyVariant equals the string '2'" If...
1
by: John_H | last post by:
Re: ASP.NET 2.0 I would like suggestions or code examples on how to collect a variable length list of input data (item# & item quantity specifically). I thought that I could accomplish this...
29
by: garyusenet | last post by:
I'm trying to investigate the maximum size of different variable types. I'm using INT as my starting variable for exploration. I know that the maximum number that the int variable can take is:...
1
by: jlt206 | last post by:
This code <?php include("counter.php")?> on the webpage produces the count number. (function code below) I want to place the current number into a variable $MemberNo or into a FormField to be sent...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.