Skip to content

Instantly share code, notes, and snippets.

@wboykinm
Created August 20, 2012 15:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wboykinm/3405063 to your computer and use it in GitHub Desktop.
Save wboykinm/3405063 to your computer and use it in GitHub Desktop.
Passing geometry from client to DB
<?php
$username = //[user];
$password = //[wouldntyouliketoknow];
$hostname = "localhost";
$database = "geosproc_btvwards";
$dbh=mysql_connect($hostname, $username, $password) or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ($database);
// OBQtypeQ:QFeatureQCOQgeometryQ:OBQtypeQ is my dumb version of {"type":"Feature","geometry":{"type"
// i.e., what the json string should start with
if ( strpos( $_POST['hoods'], 'OBQtypeQ:QFeatureQCOQgeometryQ:OBQtypeQ' ) == 0 ){
$data = mysql_query("INSERT INTO hoods9 (json) VALUES ('".$_POST['hoods']."')");
}
if (!$data) {
echo "Error";
} else {
echo "Sweet";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment