Formating numbers in a form after retrieving from an SQL database

Hello everyone,
I am using php to populate a form using numbers taken from an sql database.  I am having a hard time showing decimal places in those numbers.  The code I am using in the value section of the form is:
value="<?php if (isset($_POST['unit_price_1'])) {
     echo htmlentities( $_POST['unit_price_1'], ENT_COMPAT, 'UTF-8');
     } else {
          echo htmlentities($row_getInvoice['unit_price_1'], ENT_COMPAT, 'UTF-8');
     } ?>" />
This code rounds all numbers up and eliminates decimal places.  I am trying to show dollars and cents.
How do I alter the code to accomplish what I want.
Jeff

Not sure what might come in your way here, so I just made the following simple test by using a static value rather than one which gets derived from a recordset (the source shouldn´t matter), and this works well for me without seeing the value altered in any way:
<?php
$value = "10.22";
?>
<input type="text" name="whatever" value="<?php echo htmlentities($value, ENT_COMPAT, 'UTF-8'); ?>" />
However,. for displaying numeric values you really don´t need to use  htmlentities/ENT_COMPAT etc etc -- that´s something you´d rather use for displaying textual contents containg special characters like umlauts and such.
If all you need is to add some degree of protection by escaping special HTML characters (<, >, &, etc.), the function htmlspecialchars() will only be escaping just these characters and leave the rest "as is", whereas htmlentities() is notably more rigi, because this function will convert all applicable characters to HTML entities -- but again: at this point you´re just *displaying* some numeric value, that is, such security measures are pretty much pointless in this scenario, because there´s nothing to protect from ;-)
Please test what happens when doing away with the htmlentities - thing.
Cheers,
Günter

Similar Messages

  • Migrating from Azure SQL Database to SQL Server VM

    I'm looking for steps/documentation to migrate a database from Azure SQL Database to SQL Server VM in the cloud. I want to make an app whose data is initially hosted in the former. Due to a few reasons, I might have to migrate to SQL Server VM. I'd
    like to design the app such that ideally there is no downtime. Looking for guidance...

    You can create bacpac file from Azure SQL database and Restore this bacpac file into SQL Server VM or any other place.
    Please refer below URL for more details:
    http://blogs.msdn.com/b/mast/archive/2013/03/04/different-ways-to-backup-your-windows-azure-sql-database.aspx
    dharampal sikhwal

  • Display images from a SQL database

    I want to display images from a SQL database. The images are in a table under a specific column and are stored as a link to the image. How would I display the images from the column in LabVIEW?
    I'm using LabVIEW 2013 version 13 and SQL Server 2012
    Paul Power
    I have not lost my mind, it's backed up on a disk somewhere

    Hi PauldePaor,
    I hope you are well.
    Once you have pulled the data from the database into LabVIEW in a string form (or path), you can simply use the Read BMP File (Or jpg, png depending on the file type) VI.
    More information can be found here:
    http://digital.ni.com/public.nsf/allkb/02971A30F5D8FC6986256A0A004F11A0
    Kind Regards,
    Aidan H
    Applications Engineer
    National Instruments UK & Ireland

  • Generating next number from the SQL database using java

    Hi friends, I have a problem and need your help. I am working on a project about submitting claims form through the adobe PDF file and SQL database. I have problem working on a web service (written in java) that will generate the next Invoice Number from the SQL Database table. The field type for the column is text(var char). *Example: I first need to get into the table and search for the last Invoice number in the table and if the last invoice number in the table from the database is 3, i would want to generate the next number which is 4 and filled it up in the PDF file through web service that i am implementing. Can you all provide me some guidelines on how to implement this method in my web service?
    Thanks a lot. I need it by today. Hope someone can reply this as soon as possible.
    Lim89
    Edited by: LIM89 on Apr 2, 2008 7:10 PM

    far simpler to use a sequence generator, which most databases support.
    Suggested method to get the max value in the column is NOT secure, unless you lock the entire table for update before you do so, which is a severe performance penalty.

  • Text format appears to be diffrent while retrieving from FR

    Hi All,
    We have a Financial report , designed with the help of FR studio. One of Columns of this FR is named "Affiliate Id " Which is pulling a unique ID for different companies. These Affiliate Ids are being pulled out from a data form where the entries are being submitted with the help of Smartview / Workspace.
    Now the issue is that when FR is Run then the Affiliate Ids are Displayed in the following form: i mean the numeric values are being displayed Upto 6 decimal Places which is not the Way its should be and we want it to be without any decimal value as they are submitte in data form without any decimal value.Irony is that in the same FR we are getting the values in one another column(Governmenr Id) in proper way( Shown Below )
    Affiliate ID
    1063.000000
    1063.000000
    Aff ID Undefined
    1557.000000
    1489.000000
    1063.000000
    Government ReportID
    31480
    31709
    In both The Columns, Values are being pulled as celltext and formulaes being used are:
    For Affiliate ID:
    <<CellText("Grid1", Cur, C(A), 1)>>
    For Government ReportID:
    <<CellText("Grid1", Cur, D(B), 1)>>
    So Please help in knowing that what may be the possible cause of Affiliated ID being deisplayed with such huge decimal values how i can correct that, through FR studio or from workspace/ Data form from where it is being pulled.
    Note:Even if we See the Affiliated ID in data form after submitting and refreshing, its picking decimal places there also same way.

    Hi Thanos,
    Version Used:11.1.1.3
    Sorry for the confusion.
    Yes We are submitting cell text.
    For non-numeric data, we dont have any issue. Like if we submit "Aff ID Undefined",then its been shown in FR without any issue.
    But When any numeric value is pulled in FR, that comes with 6 decimal places like 1234 shows as 1234.000000. You can see the below pattern(directly copied from FR)
    Affiliate ID
    1063.000000
    1063.000000
    Aff ID Undefined
    1557.000000
    1489.000000
    1063.000000
    Note: Issue is specifically with the Cell text submitted in data form through smartview/Excel. If we submit thorugh workspace, then we dont face this issue.
    I hope it helps you understand the whole aspect.
    Thanks ,
    Satish

  • I want resize the image and set position after retrieving from oracle datab

    How can I display image on web page after retrieving it from oracle database. Display is not problem but resize that image and position is very dificult .Please send me Guideline about blob object todisplay and resize it in web pages

    I tried to do the suggetion made by you but I was not able to solve the issue. I think I am close to it and with your help I should be able to resolve it. Let me explain you the brief about this issue.
    1. Another group uses Oracle Apex to load the images in to the database.
    2. I am fetching this data fron Oracle and displays in to Webpage using PHP.
    This is so far I tried. Please bear with me if I am doing anything wrong.
    1.I created program.php which calls the <IMG> as suggested by you.Snippet of the code is
    <div><img src="/oracle/image_story.php" alt="Image Stories" width="900" height="500" /></div>
    2. In the image_story.php, I used the following code.
    <?php
    $query = "SELECT *
              FROM IMAGE_STORY WHERE image_id = 50";
    if ($result = run_oracle($query, 'select')) { // Run the query.
         $num_results = count($result);
         if ($num_results > 0) {
         foreach($result as $row){
              $img = $row['DOCUMT']->load();
              header("Content-type: image/pjpeg");
              echo $img;
              //echo '<div><img src="'.$img.'" alt="Image Stories" width="900" height="500" /></div>';
    ?>
    When I run the program.php,Image is not displayed and it is showing as "X". To troubleshoot the issue,I run the image_story.php and echo $img is giving me the weird character like,
    "ÿØÿàJFIFddÿìDuckyPÿîAdobedÀÿÛ„          
    I used PL/SQL developer as a client to access the BLOB field from the database and in the HTML view, it is giving me the same output.
    Select * from image_story a where a.image_id = 50
    I am not sure the issue is with the MIME-TYPE,ENCODING or I am missing something here. I tried lot of Content-Type.
    Please guide me.

  • Retrieve image from my sql database using jsp

    I want to retrieve image from my sql (blob type) & save it in given relative path in server .(using jsp and servlets)
    please give me some sample codes.

    PreparedStatement pst = null;
      ResultSet rs=null;
    pst = conn.prepareStatement("select image from imagedetails where imageid='"+imageid+"'");
    rs=pst.executeQuery();
    while(rs.next())
                                byte[] b=rs.getBytes("image");
                                FileOutputStream fos=new FileOutputStream("c://image.jpg");
                                fos.write(b);
                            } hi this the code to retrieve the image from DB and write to a file.

  • Check Stored Procedures after Migration from MS SQL Server 2008 to Oracle11

    I successfully migrated my application database (azteca) from MS SQL Server 2008 to Oracle 11g R2. After migration, I found there are few stored procedures are not valid. How do I check these invalid stored procedures and find what is wrong with them by using SQL Developer? Thanks for your help.
    Kevin

    Hi Kevin,
    You posted quite a bit today, so perhaps you have already worked this out. If not...
    1. View -> Reports -> Data Dictionary Reports -> All Objects -> Invalid Objects [for a specific schema name]
    2. Next, for each invalid stored procedure listed in (1)...
    a. Open in the code editor from the Connections navigator tree
    b. Click on the Compile icon (two gears meshed together) in code editor tool bar.
    c. Look in the Compiler log pane for errors.
    d. Correct the errorsOf course, success in addressing any errors depends on your skill level dealing with Oracle PL/SQL.
    Also, it may be helpful to read over section *3.2 Stored Procedures* in the supplementary migration guide:
    http://docs.oracle.com/cd/E35137_01/doc.32/e18462/trig_stored_proc.htm#CHDEIGBC
    Regards,
    Gary
    SQL Developer Team

  • Reading/Writing Data from a SQL Database

    Hi,
    I have a data structure called 'Quote' which contains a number of different variables and controls ranging from text boxes, check boxes and radio buttons, i need to be able to read and write this from a database.
    First I think a description of my overall project is needed:
    Project Description
    I have been given a brief that basically says: i have to create a programmed solution in VB to solve a problem. This problem can be anything we like, and I personally have chosen to create a program that manages quotes for building Log Cabins (this is very contrived and far from anything someone would do in the real world).
    My solution will allow a generic user to create a quote (using a form with controls such as text boxes, check boxes, radio buttons) , and then save this to file. These users may then wish to load/edit this quote at a later date, from another form.
    Whilst completing this project, i'll only have up to about 5 records (quotes) within the system, so i dont need the ability to store hundreds of records. And each record will be relatively short, with only about 10-15 data items within the data structure.
    Also the Admin (or business owner in this case) need to be able to view all saved quotes in a presentable format, and edit them if needs be, from within this same program.
    This solution does not need to be absolutely perfect and 100% efficiently coded, or have all the bells and whistles a real-world program would have. This is for an A level computing project by the way.
    So basically, i need to be able to read from the database (to populate a Data Grid (i imagine this is best way?)) and so Admin can access any quote and edit it (editing is not vital, but viewing/printing is. Maybe i should stop at just viewing any quote?). Also i need generic users to be able to fill in the Edit Quote form and then save this data into the database.
    And is a data structure really required for me to use a database?
    I've never used databases in VB before (but have used them elsewhere, mainly Access) and so am completely new to this. Any help will be much appreciated.
    Thanks

    this is just a dataset i created using the dataset designer.
    OK, so i have the dataset called "MyDataSet".
    I also have the following variables:
    Code Snippet
    Dim FloorSpace As Int32
    Dim NoOfBedrooms As Int32
    Dim NoOfBathrooms As Int32
    Dim EnSuites As Int32
    Dim LuxKitchen As Boolean
    Dim LuxCabin As Boolean
    Dim Flooring As Boolean
    Dim VoiceLighting As Boolean
    Dim SolarPanels As Boolean
    Dim IntegralSound As Boolean
    Dim WindowFrames As String
    Each of which relates directly to a column in the dataset (data type matches too).
    What i need to do now, is to save these variables as an additional record in MyDataSet. And then save MyDataSet to file, so it can be loaded again next time the program is run and more additional records added. (all files are local by the way).
    how would i go about this?

  • How to use java to create an XML document from an SQL database?

    Hi,
    I'm a complete novice at XML and have only recently started programming in Java.
    I'm currently trying to develop a package in Java 1.1.8 which requires a set of very specifically formatted XML documents. These documents would need to be updated regularly by people with no knowledge of Java and I would like to make it as simple as possible.
    Since the data will already be in an SQL database, I thought it might be possible to generate the XML documents from the data using a small Java application, but I'm not too sure how to go about this or if this is even possible! Any help or pointers in the right direction would be very much appreciated.
    Louise

    Do you have the option of upgrading to a newer version of the JDK?
    JAXB does what you are wanting very easily. Also there are tools if you don't want to write your own. JAXB is available as early release on Sun's site as is the newest JDK. Otherwise, you have to design a factory and interface that will do this for you (which is what JAXB basically is in a very simplified view).

  • How to create a setup for window form application including the related sql database?

    i have created a simple window form application project that have only 2 form..
    1st one for login in which it'll check the userid n password from database.if both are correct then it will go to 2nd form.
    now i want this project to run in another computer.
    i created a setup file but its showing some error regarding the database instances connection..
    so if anyone can tell me in details how to create the setup file then it'll b a great help..
    thanx in advance..

    Hi,
    Consider the above scenario,I suggest you to use the SQL Server Compact+ ClickOnce Deployment, A Compact SQL database is a file that can be bundled with your application installation. Below is a link guiding you through the creation process of a SQL Compact
    database.
    http://technet.microsoft.com/en-us/library/ms173009.aspx
    The following link discusses setting up the necessary dependencies and prerequisites for SQL Server Compact. (Note, you will need to scroll to the section entitled Private File–Based Deployment.)
    http://msdn.microsoft.com/en-us/library/aa983326(v=VS.100).aspx
    A ClickOnce Deployment can help you publish your application attach compact SQL database into client machine.
    Regards,
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • How can I map an image (JPEG) from the SQL database image string

    I saved the image into SQL database, see attachment (SaveImage2SQLDB.rar), while I have some trouble to retrieve the image. I also attached the vi which I used to convert the string to image. The string already has a value I obtained from the database. Can anyone tell me the reason why it didn't work.
    Thanks in advance.
    Jane
    LabVIEW 2012, VDM 2012
    Attachments:
    convertstringtoimage.vi ‏78 KB
    SaveImage2SQLDB.zip ‏27 KB

    Hi Jane,
    What exactly isn't happening correctly?  The conversion or the retrieval? 
    This discussion forum may be of some use: http://forums.ni.com/t5/LabVIEW/image-from-compressed-string/m-p/2207894
    Matt S.
    Industrial Communications Product Support Engineer
    National Instruments

  • Is it possible to migrate WebCenter Portal data from a SQL database to an Oracle database?

    We have our WebCenter Portal applications set up using a SQL database. Now we're wanting to migrate to an Oracle database and I'm wondering if that is possible.

    Yes it should be possible though i have not tried it myself. You basically export a file from mds ( xml) and import it into oracle db.
    Thanks
    manish

  • Transfering data from External SQL database to BW

    Hi Experts,
         I am trying to extract data from an External SQL Database  in BW using      
         DB Connect.
        1. I have created a  DB Source System.
        2. Using this Source System I have generated a Datasoure.
           ( following all the naming conventions for Table Names and Field Names)
        Till this point everything is OK.
        Then I assign a Infosource and try to upload the data into PSA.
        The process is never complete and I am getting a message
       <i> <b>Request still running
        Diagnosis
        No errors could be found. The current process has probably not finished yet.
        System response
        The ALE inbox of the SAP BW is identical to the ALE outbox of the source
        system
        and/or
        the maximum wait time for this request has not yet run out
        and/or
        the batch job in the source system has not yet ended.
        Current status
        No Idocs arrived from the source system</b>.</i>
         please help me.
      thanks
      arshad

    please first tell me which wich user you connect and the exact name of your table/view: is it dbo.table?
    as I said, better create a user in your SQL, log with this user and create a view.
    in RSBDC select this view and generate datasource. Check if you see data.
    if yes, the load shouldn't fail.
    We came across the same issue: login with sa, accessing a dbo. object; seing the data in RSDBC but nothing loading...
    let me know
    Olivier.

  • Is it possible to load SWF files from an SQL database?

    Hi all, I am very new to flash (I am primarily a C'# developer!) and I have been asked to investigate the possibility of doing the following;
    Create an application that allows swf files to be uploaded and stored inside of a SQL database as binary data (Why a database is a long story!)
    Allow this binary data to be extracted via a http request to be dynamically loaded inside of a web page.
    Now the first part was easy. I have all of my swf's uploaded and stored inside of the database. I have code that can make a request for the binary and write it to the response, so far so good. Now this is where I am stuck.
    I thought I could dynamically load the swf binary data by creating a very basic swf that simply contains a movie clip holder and for now a simple loadMovie statement. My idea being that I can could provide a url for the loadMovie statement that returns the swf binary data. This is where I have ground to a halt.
    I can see the call being made from the swf, I can see the data being returned but I cannot get it to render. I remember seeing an article some time agao where someone stated that they had used this method with success but I cannot find now. Has anyone ever done anything like? Is it even possible? Am I missing something simple?
    I have tried to return both the raw binary data and also used response.write but to no avail. Can anyone help?

    You are possibly trying to load AS3 swf into an AS2 Container at least the use of loadMovie() points in that direction. Be sure to use AS3 and target at least Flash 9 in your Loader/Main.swf. Also the AS3 concept of how to load swfs  differs a lot from the old concept.
    Look into the docu:
    http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/Loader.ht ml
    But the biggest Problem seems to me -what you mentioned- that Loader needs a (defined) URLRepuest and since your swf files have no "real" URL and you surely don`t want to let the user directly write to your server, a workaround would be to write the BinaryStream with AIR-functionality to a local installlation directory and load it then from there.

Maybe you are looking for

  • How do I add a computer to network with my MacBook Pro?

    I'm having difficulty getting my new MacBook Pro to recognize my PC on my home network in order to print.  The MacBook Pro is not accepting the software for the hp printer.  The message window states "...can't open the hp-all-in-one installer because

  • OS authentication gives ORA-01005

    We are new to ODP.NET and are trying to connect to our Unix databases which are configured with OS authentication. When we connect with sqlplus we enter "/" as the userid, leave the password column null and enter the database name in the required loc

  • Is it possible to use Magnetic Strip Card in Java Card

    Can Any body knows that is it possible to use magnetic strip card instead of IC MicroProssesor card in Java Card technology ? is it possible to write java card applet on magnetic strip card ? Please Help me in this topic Thanx in advance

  • Viewing current Connection Properites

    Fellow SQLers, Using SQL 2008R2 I am trying to understand why a dbo-owner is seeing Server Not Available when they right click on their DB, go to properties, then select View Conneciton Properties in SSMS. This Server Not Available value appears in a

  • MASS Hiring Action

    Dear As per the client requirement i have run a Hiring action for 100 employees every month. Instead of running a hiring action for each employee every time, is there any solution to run a hiring action for 100 employees at one single instance. We ha