refmySQL.php
<?php
require("dbinfo.php");
if($ssh = ssh2_connect('127.0.0.1', 22))//If it connects
{
if(ssh2_auth_password($ssh, 'user', 'pass'))//User and password to use
{
$stream = ssh2_exec($ssh, 'cat /home/jason/Desktop/test');//command to execute
stream_set_blocking($stream, true);
$data = '';
while($buffer = fread($stream, 30))//read from stream
{
$data = $buffer;
}
$latlng = explode(";", $data);
echo $latlng[0]; //output for testing
echo "</br>";
echo $latlng[1];
$lat = explode(",", $latlng[0]);
$lng = explode(",", $latlng[1]);
echo "</br>";
$Declat = round($lat[0]+((($lat[1]*60)+($lat[2]))/3600),6);
$Declng = round($lng[0]+((($lng[1]*60)+($lng[2]))/3600),6);
echo $Declat; //output for testing
echo "</br>";
echo $Declng;
fclose($stream);//close stream
}
// Opens a connection to a MySQL server
$connection=mysql_connect (localhost, $username, $password);
if (!$connection) {
die('Not connected : ' . mysql_error());
}
// Set the active MySQL database
$db_selected = mysql_select_db($database, $connection);
if (!$db_selected) {
die ('Cant find db : ' . mysql_error());
}
// Insert new row into table
$query = "INSERT INTO markers(lat,lng) VALUES ($Declat,$Declng)";
$result = mysql_query($query);
if (!$result) {
die('Invalid query: ' . mysql_error());
}
}
?>

New Topic/Question
Reply




MultiQuote


|