$sql="INSERT INTO gpscoordinates (UserName, Password1, Group1,Latitude,Longitude)
VALUES
('$_POST[User]','$_POST[Password1]','$_POST[Group1]','$_POST[Latitude]','$_POST[Longitude]') ON DUPLICATE KEY UPDATE (Latitude='$POST_[Latitude]', Longitude ='$_POST[Longitude]')";
<?php
$dbhost = 'xxxx';
$dbuser = 'xxxx';
$dbpass = 'xxxxx';
$dbname='xxxxx';
$con = mysql_connect("$dbhost","$dbuser","$dbpass");
mysql_select_db($dbname);
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
$sql="INSERT INTO gpscoordinates (UserName, Password1, Group1,Latitude,Longitude)
VALUES
('$_POST[User]','$_POST[Password1]','$_POST[Group1]','$_POST[Latitude]','$_POST[Longitude]')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "1 record added";
mysql_close($con)
?>
if (isset($_POST['submit'])){
$user = mysql_real_escape_string($_POST['User']);
$password = mysql_real_escape_string($_POST['Password1']);
$group = mysql_real_escape_string($_POST['Group1']);
$latitude = mysql_real_escape_string($_POST['Latitude']);
$longitude = mysql_real_escape_string($_POST['Longitude']);
echo "User is $user<br />";
echo "password is $password<br />";
echo "Group is $group<br />";
echo "latitude is $latitude<br />";
echo "longitude is $longitude<br />";
$sql="INSERT INTO gpscoordinates (UserName, Password1, Group1,Latitude,Longitude)
VALUES ('$user','$password','$group','$latitude','$longitude') ON DUPLICATE KEY UPDATE (Latitude='$latitude', Longitude ='$longitude')";
}
array(0) { }
Notice: Undefined index: User in /home/content/15/6807515/html/loaddata.php on line 20
Notice: Undefined variable: sql in /home/content/15/6807515/html/loaddata.php on line 47
Error: Query was empty
error message without quotesarray(0) { }
Notice: Use of undefined constant User - assumed 'User' in /home/content/15/6807515/html/loaddata.php on line 20
Notice: Undefined index: User in /home/content/15/6807515/html/loaddata.php on line 20
Notice: Undefined variable: sql in /home/content/15/6807515/html/loaddata.php on line 47
Error: Query was empty
<?php
error_reporting(E_ALL);
var_dump($_POST);
$dbhost = 'xxxxx';
$dbuser = 'xxxx';
$dbpass = 'xxxx';
$dbname='xxxx';
$con = mysql_connect("$dbhost","$dbuser","$dbpass");
mysql_select_db($dbname);
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
if ($_POST['User'] != ''){
$user = mysql_real_escape_string($_POST[User]);
$password = mysql_real_escape_string($_POST[Password1]);
$group = mysql_real_escape_string($_POST[Group1]);
$latitude = mysql_real_escape_string($_POST[Latitude]);
$longitude = mysql_real_escape_string($_POST[Longitude]);
echo "User is $user<br />";
echo "password is $password<br />";
echo "Group is $group<br />";
echo "latitude is $latitude<br />";
echo "longitude is $longitude<br />";
$sql="INSERT INTO gpscoordinates (UserName, Password1, Group1,Latitude,Longitude)
VALUES ('$user','$password','$group','$latitude','$longitude') ON DUPLICATE KEY UPDATE (Latitude='$latitude', Longitude ='$longitude')";
}
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "1 record added";
mysql_close($con)
?>
array(0) { }
Notice: Undefined index: User in /home/content/15/6807515/html/loaddata.php on line 20
Notice: Undefined variable: sql in /home/content/15/6807515/html/loaddata.php on line 47
Error: Query was empty
array(0) { }
Notice: Undefined index: User in /home/content/15/6807515/html/loaddata.php on line 20
Notice: Undefined variable: sql in /home/content/15/6807515/html/loaddata.php on line 47
Error: Query was empty
$sql="INSERT INTO gpscoordinates (UserName, Password1, Group1,Latitude,Longitude)
VALUES
('$_POST[User]','$_POST[Password1]','$_POST[Group1]','$_POST[Latitude]','$_POST[Longitude]')";
private void putServerData(String gotBread, String teat, String lockerroom, String spotX, String spotY) {
String db_url = "http://www.mypage.com/loaddata.php";
InputStream is = null;
ArrayList<NameValuePair> request = new ArrayList<NameValuePair>();
request.add(new BasicNameValuePair("User", gotBread));
request.add(new BasicNameValuePair("Password1", teat));
request.add(new BasicNameValuePair("Group1", lockerroom));
request.add(new BasicNameValuePair("Latitude", spotX));
request.add(new BasicNameValuePair("Longitude", spotY));
try {
HttpClient httpclient = new DefaultHttpClient();
Log.d("log_tag", "Got this far " + httpclient);
HttpPost httppost = new HttpPost(db_url);
httppost.setEntity(new UrlEncodedFormEntity(request));
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
is = entity.getContent();
String s = convertStreamToString(is);
Log.d("log_tag", "Result: " + s);
} catch (Exception e) {
e.printStackTrace();
Log.d("log_tag", "Error: " + e.toString());
}// catch
}// send
my original php code<?php
$dbhost = 'xxxxx';
$dbuser = 'xxxxx';
$dbpass = 'xxxxx';
$dbname='xxxxxx';
$con = mysql_connect("$dbhost","$dbuser","$dbpass");
mysql_select_db($dbname);
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
$sql="INSERT INTO gpscoordinates (UserName, Password1, Group1,Latitude,Longitude)
VALUES
('$_POST[User]','$_POST[Password1]','$_POST[Group1]','$_POST[Latitude]','$_POST[Longitude]')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "1 record added";
mysql_close($con)
?>
Table structure for table `gpscoordinates`
--
CREATE TABLE `gpscoordinates` (
`UserName` varchar(50) NOT NULL,
`Password1` varchar(50) NOT NULL,
`Group1` varchar(50) NOT NULL,
`Latitude` varchar(50) NOT NULL,
`Longitude` varchar(50) NOT NULL,
`dp_datetimes` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
FULLTEXT KEY `UserName` (`UserName`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
--
-- Dumping data for table `gpscoordinates`