java - Error in connecting to PostgreSQL database using data inserted from android application through PHP -


my current android application allows user key in chat room name i'll utilizing name stored database name. hence name stored used connect database using php web service. understand there're solutions editing pg_ident.conf file, allowing www-data recognized 1 of users access database. however, i'm hoping have better solution. in advance given.

this error message got

warning: pg_connect() [function.pg-connect]: unable connect postgresql server: fatal: role "www-data" not exist.

php code (blabla.php)

<?php  $host = "localhost";  $user = "bbcc";  $db=$_post['name'];  $passwd = "abc";   $con = pg_connect("host=$host dbname=$db user=$user password=$passwd") or die ("could not connect server\n" . pg_last_error()); ?> 

java code snippet

   private void valid() {           string room = "abcd";         try{              httpparams params = new basichttpparams();              httpconnectionparams.setconnectiontimeout(params, 20 * 1000);              httpconnectionparams.setsotimeout(params, 30 * 1000);              httpclient httpclient = new defaulthttpclient(params);              httppost httppost = new httppost("http://111.11.111.000/script/blabla.php");              list<namevaluepair> namevaluepairs = new arraylist<namevaluepair>();                  namevaluepairs.add(new basicnamevaluepair("name", room));              httppost.setentity(new urlencodedformentity(namevaluepairs));              httpresponse response = httpclient.execute(httppost);         }catch(exception e){             e.printstacktrace();         }   } 

check settings pg_hba.conf

this file controls: hosts allowed connect, how clients authenticated, postgresql user names can use, databases can access. records take 1 of these forms:

local      database  user  method  [options] host       database  user  cidr-address  method  [options] hostssl    database  user  cidr-address  method  [options] hostnossl  database  user  cidr-address  method  [options] 

Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -