Web Analytics Made Easy -
StatCounter Insert array value to database but all value are 0 - CodingForum

Announcement

Collapse
No announcement yet.

Insert array value to database but all value are 0

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Insert array value to database but all value are 0

    I am new in MySQL

    this is my coding(united.jpeg),

    i print the insert comment and the following are shown:

    insert into windrose (wd,ws,ms,md) values (' 19 ',' 2.3 ',' ',' ')

    but i dont know why all my data insert to mysql database are 0,

    i set wd as integer, ws as double , ms as double, md as integer.

    please i need help

    thanks
    Attached Files

  • #2
    The quotes will tell mysql to interpret the values as strings. Remove the quotes.

    Comment


    • #3
      Thank you for your reply,

      but is there any solution to turn the value to integer? because i need to use the data in db for calculation.

      Comment


      • #4
        and sorry what quote do you mean?

        Comment


        • #5
          Originally posted by jason_loh33 View Post
          and sorry what quote do you mean?
          I'm referring to the single quotes you put around the numbers. Take them out.

          Comment


          • #6
            when i take out the quotes you said,

            db have no data inserted after running the codes.

            and another thing, when i change the inserted datatype in db to string the data will be shown like:

            <td>2.1&n


            the value 2.1 is the value i wanted to used for calculation.

            is there any solution for this?

            Comment


            • #7
              You haven't provided any code for us to review/troubleshoot, but it's likely that you're using a var which holds the data to be inserted and that var includes a \n line terminator.

              Comment


              • #8
                Click image for larger version

Name:	Untitled2.jpg
Views:	1
Size:	50.9 KB
ID:	2270493Click image for larger version

Name:	Untitled.jpg
Views:	1
Size:	47.3 KB
ID:	2270494

                i am taking data from a wheather website,

                and these are my coding

                Comment


                • #9
                  Images of code are useless. You need to post the actual code here (inside either [code] or [php] tags) for us to help.
                  Stephen
                  Learn Modern JavaScript - http://javascriptexample.net/
                  Helping others to solve their computer problem at http://www.felgall.com/

                  Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

                  Comment


                  • #10
                    index.php.txt

                    the following is my coding
                    Attached Files

                    Comment


                    • #11
                      intval will only work on integers and returns 0 when error occurs. You cannot use intval with floats.
                      Don't use old mysql library
                      The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets
                      When a white horse is not a horse

                      Comment


                      • #12
                        You still haven't posted the code here - no one is going to open strange files to view your code as we don't know if the files contain viruses.
                        Stephen
                        Learn Modern JavaScript - http://javascriptexample.net/
                        Helping others to solve their computer problem at http://www.felgall.com/

                        Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

                        Comment


                        • #13
                          I already get all contact number (name,number ) in array and display in listview.. i already know way to insert single value into database using volley but i dont know how to insert array.

                          Comment


                          • #14
                            Pictures are for hanging on the wall. Post your code.
                            To save time, lets just assume I am almost never wrong.

                            The XY Problem
                            The XY problem is asking about your attempted solution (X) rather than your actual problem (Y). This leads to enormous amounts of wasted time and energy, both on the part of people asking for help, and on the part of those providing help.

                            Make A Donation https://www.paypal.me/KevinRubio

                            Comment

                            Working...
                            X