ok..so i have database which contains a table girls with fields Serial(int) hits(int) name(text) ...following is code for homepage
<?php
ini_set("display_startup_errors", "1");
ini_set("display_errors", "1");
error_reporting(-1);
session_start();
$con = mysql_connect("localhost","gaurav","");
mysql_selectdb("website",$con);
$sql = "Select COUNT(*) from girls";
$var = mysql_query($sql,$con);
$count=mysql_result($var, 0);
$index1 = rand(1,$count);
$index2;
while(1)
{
$index2 = rand(1,$count);
if($index1 != $index2)
break;
}
$_SESSION['index1'] = $index1;
$_SESSION['index2'] = $index2;
$sql = mysql_query("SELECT * FROM girls WHERE Serial=$index1");
$row = mysql_fetch_array($sql);
$name1 = $row['name'];
$hits1 = $row['hits'];
$sql = mysql_query("SELECT * FROM girls WHERE Serial=$index2");
$row = mysql_fetch_array($sql);
$name2 = $row['name'];
$hits2 = $row['hits'];
echo <<<ECO
<html>
<head>
<script src="jquery.js"></script>
<script language="javascript" type="text/javascript">
<!--
//Browser Support Code
function in1(){
var ajaxRequest;
try{
// Opera 8.0+, Firefox, Safari
ajaxRequest = new XMLHttpRequest();
} catch (e){
// Internet Explorer Browsers
try{
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try{
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e){
// Something went wrong
alert("Your browser broke!");
return false;
}
}
}
ajaxRequest.open("GET", "girls.php", true);
ajaxRequest.send(null); }
function in2(){
var ajaxRequest;
try{
// Opera 8.0+, Firefox, Safari
ajaxRequest = new XMLHttpRequest();
} catch (e){
// Internet Explorer Browsers
try{
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try{
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e){
// Something went wrong
alert("Your browser broke!");
return false;
}
}
}
ajaxRequest.open("GET", "girls1.php", true);
ajaxRequest.send(null); }
//-->
</script>
</head>
<body >
//some html code
<a href="index.php" onclick="in2();"><img src="t1.png" id="t1" /></a>
<a href="index.php" onclick="in1();"><img src="t2.png" id="t2" /></a>
</body>
</html>
ECO;
?>
and girls.php is
<?php
ini_set("display_startup_errors", "1");
ini_set("display_errors", "1");
error_reporting(-1);
session_start();
$con = mysql_connect("localhost","gaurav","");
mysql_selectdb("website",$con);
$myvar = $_SESSION['index1'];
$sql = "UPDATE girls SET hits = hits + 1 WHERE Serial = $myvar";
mysql_query($sql,$con);
?>
similarly is girls1.php ..when i click t1.png or t2.png the hits are supposed to be incremented...but its not happening so when i hosted it...