×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Dec 2010
    Posts
    2

    Question post data on mysql using php or html

    Hi,

    I have a mysql database and i add string data to it using a web html form. The html form inserts data to the table using php which is here

    PHP Code:
    <?php

    $con 
    mysql_connect("mysql10.000webhost.com","a7456565_zzz","zzz");
    if (!
    $con)
      {
      die(
    'Could not connect: ' mysql_error());
      }

    mysql_select_db("a7456565_db"$con);

    $sql="INSERT INTO GPS (lat,lon)
    VALUES
    ('
    $_POST[lat]','$_POST[lon]')";

    if (!
    mysql_query($sql,$con))
      {
      die(
    'Error: ' mysql_error());
      }
    echo 
    "1 record added";
    mysql_close($con)

    ?>
    how can i add data to it using JAVA ME?
    I add data using a html form which works fine.
    I tried the following but is not working

    Code:
    HttpConnection conn =
    ("http://www.test.it" + "?TextField=Hello&TextField2=Hello2&Submit=Submit");
    conn.close();

  2. #2
    Super Contributor
    Join Date
    Apr 2003
    Location
    USA, CA
    Posts
    7,191

    Re: post data on mysql using php or html

    Your PHP code is expecting the data through HTTP POST. If you add the data in the URL like you have done in the Java Example, you are sending the data with HTTP GET. If that's ok for you, then change the "$_POST" strings in your PHP sample to "$_GET"
    If you want to use POST instead, check this code sample
    http://wiki.forum.nokia.com/index.ph...est_in_Java_ME

    Hartti

  3. #3
    Super Contributor
    Join Date
    Mar 2005
    Location
    Paris
    Posts
    814

    Re: post data on mysql using php or html

    also your parameters are named incorrectly. you php script expects lat and lon, not TextField and TextField2

  4. #4
    Registered User
    Join Date
    Dec 2010
    Posts
    2

    Re: post data on mysql using php or html

    i managed to do it. thanks.

Similar Threads

  1. HTTP POST, sending data, any idea how to fetch in PHP?
    By imarenic in forum Mobile Java Networking & Messaging & Security
    Replies: 4
    Last Post: 2003-11-13, 21:05

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×