我可以从javascript函数获取url。 我需要使用php代码将相同的url存储在我的数据库中。

<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>
<script type="text/javascript"> 
function testme(data){var i = data.href ;alert(i);
document.getElementById("log").innerHTML=data.href;}
</script>
<g:plusone callback="testme" href="http://stackoverflow.com/"></g:plusone> <!-- div for google post-->
<?php
include('config.php');          //config file
echo "<b id=".log."></b>";
$query1=mysql_query("insert into addd values('log')");
?>

This is my code for click event for google post. I need the url to be saved in mysql using php

get the full URL path in JavaScript:
var newURL = window.location.protocol + "//" + window.location.host + "/" + window.location.pathname;

If you need to breath up the pathname:
var pathArray = window.location.pathname.split( '/' );

Then access the different parts by the parts of the array, like
var secondLevelLocation = pathArray[0];

you need to make an ajax call

$.ajax({
  url: "test.html",
  context: document.body
}).done(function() {
  $( this ).addClass( "done" );
});

java script is client side script. you need to pass data from client side to server side either posting form or by ajax request.

Please note the Javascript code execute in Client not in server. Your php will get executed in server and hence it will not get the value of log..

$.ajax({
  url: utl-to-save-data,
  data: {"log":log}
}).done(function() {
  //sussess code;
});