PHP constantly regenerates division by zero at line that I've defined my MySQL connection info. the code uses AJAX to change a variable, so the page can regenerate a new string from database.
Here's the code:
<script type="text/javascript">
function newtrl()
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("tr").innerHTML=xmlhttp.responseText;//the input button's ID, is innerHTML the right element for this?
}
}
xmlhttp.open("GET","http://www.1barg.com/page.php?trl=",true);
xmlhttp.send();
</script>
</head>
<body>
<?php
$con = mysql_connect(Localhost, bargcom/@localhost, wWI9sNXjUv);//the error line
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db(kusabax22, $con);
$tbl = "CREATE TABLE table (column varchar(255),)";
mysql_query($tbl,$con);
mysql_query("INSERT INTO table (column)
VALUES ('//some random strings)");
$trl=$_GET["trl"];
$rand = mysql_query("UPDATE `troll2` SET col = MD5(RAND()) WHERE condition=TRUE;");
$rand3 = mysql_query("UPDATE `troll2` SET col = MD5(RAND()) WHERE condition=TRUE;");// these are same to avoid T_IF error.
if ($trl==1)
{
echo "$rand";
} // if user clicked the button below, generate a random string.
else
{
echo "$rand3";
}// for when page was opened.
mysql_close($con);
?>
<form id="tr" action="page.php" method="get">
<input type="button" value="New Troll" onclick="newtrl()"/>
</form>// the button. I really don't know what to do here, so I set it to trigger the Ajax function, which I know is not the right thing to do.
</body>
Thanks in advance.