I’m new to php and am having some trouble with inserting data across multiple columns.
This is my php
<?php
mysql_connect($host,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
mysql_query("Insert into rooms (Room,DateofEvent)
Values('".$_REQUEST['room']."' AND '".$_REQUEST['DateofEvent']."')");
?>
It’s taking the result from android with this code
ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("room","Boole 1"));
nameValuePairs.add(new BasicNameValuePair("DateofEvent","2011-01-01"));
try{
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://10.0.2.2/databasewrite.php");
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
is = entity.getContent();
}catch(Exception e){
Log.e("log_tag", "Error in http connection"+e.toString());
}
}
As it is,I think the problem might be in php. It works when I have it as only one column on the insert, but as soon as put in the comma, it doesn’t
Any help would be appreciated.
Thanks
try like this ? Separate the Value using “,” not “AND”