×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Mar 2008
    Posts
    4

    sms to online database

    Hi,
    Im running a script which reads in a sms message, parses the message into three variables, encodes them and then uploads via the wi-fi on the phone to a mysql database using http post commands.

    the script appears to run fine on the phone(shows no errors), yet when I check the database the data is not entered.

    I think the problem is on the php script which i have set on the server side as it says the variables im trying to pass are "undefined index"

    --part of client code running on phone

    Code:
    def message_received(msg_id):
         global d1, d2, d3
         box = inbox.Inbox()
         msg = box.content(msg_id).lower()
         
         if msg.startswith("finish"):
             quit()
         else:    
             d1 = msg[:2]
             d2 = msg[3:5]
             d3 = msg[5:]
             upload_to_php()
    
            
             
    def upload_to_php():
        params = urllib.urlencode({'data1': d1, 'data2': d2, 'data3': d3})
        headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}
        conn = httplib.HTTPConnection("my host goes here")
        conn.request("POST", "name of php script goes here.php", params, headers)
        
        conn.close()

    --part of code running on server
    Code:
    <?php
    $data1  = $_POST['data1'];
    $data2  = $_POST['data2'];
    $data3  = $_POST['data3'];
    
    
    include "_mysql.php";
     $sql = "INSERT INTO discription( block1, block2, block3) VALUES ('$data1', '$data2', '$data3')";
    
     db_query($insert, $sql);
    
    ?>
    - i also have the "_mysql.php" running on the server, which is used to connect to the database


    anyone know what im doing wrong?

    Cheers,

    Finchy
    Last edited by finchy; 2008-03-10 at 21:42.

  2. #2
    Regular Contributor
    Join Date
    Jan 2004
    Location
    Helsinki
    Posts
    376

    Re: sms to online database

    Quote Originally Posted by finchy View Post
    Hi,
    ?>[/CODE]

    - i also have the "_mysql.php" running on the server, which is used to connect to the database

    anyone know what im doing wrong?
    Read from php.net how to access RAW PHP POST data and see what's actually inputted to the PHP script. Based on this information, you should be able to see if the problem is in the client or the server.
    Mikko Ohtamaa

    http://mfabrik.com
    http://blog.mfabrik.com

  3. #3
    Registered User
    Join Date
    Mar 2008
    Posts
    4

    Re: sms to online database

    On the server side I wrote another test script which can connect to the database fine, when I enter the vaules online.

    I was having a problem on the client side with global variables. So now im saving the sms to a txt file in the message_received function.
    in the uploadtophp function im reading in the text file and inserting it into the parameters that way.

    so now im thinking that the problem is with "headers"

    Code:
    params = urllib.urlencode({'data1': d1, 'data2': d2, 'data3': d3})
     headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}
    conn = httplib.HTTPConnection("my host goes here")
    conn.request("POST", "name of php script goes here.php", params, headers)
    Am i using the right encode method for a txt file to php and
    is there a way to set proxys and port numbers for HTTPConnection?


    Cheers

  4. #4
    Registered User
    Join Date
    Mar 2008
    Posts
    4

    Re: sms to online database

    got it working in the end. simple error in the url.
    thanks for your help


    finchy

Similar Threads

  1. Read SMS from mobile and store in Database
    By kavya_m_82 in forum General Messaging
    Replies: 2
    Last Post: 2009-08-19, 19:59
  2. Querying an online database
    By ticktock in forum Symbian
    Replies: 4
    Last Post: 2008-05-28, 12:55
  3. Distinguish between SMS
    By edcruise in forum Symbian
    Replies: 2
    Last Post: 2007-12-03, 14:34
  4. Distinguish between SMS
    By edcruise in forum Symbian Networking & Messaging (Closed)
    Replies: 4
    Last Post: 2007-11-29, 15:23
  5. Replies: 2
    Last Post: 2002-10-02, 07:15

Posting Permissions

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