Thorpe,
Thank you for the heads-up on the reserved SQL word. I changed it in the db, and the above script is now:
$_GET['ip_id'] = $ip_id;
$query5 = "UPDATE table SET spct = spct+1 WHERE block_id='" . $_GET['ip_id'] . "'" ;
$result5 = mysql_query($query5) or die("<b>mySQL Error:</b>");
if(!$result5)
{
echo 'Error processing request.';
}
else
{
echo '<B><br /><br /><font size="3">Thank you </font></B><br />
<br />
Please stand by, page redirecting shortly.';
}
This page is reached by clicking a link on the previous page, via
<a class="style1" href="ip_rec.php?ip_id='.$row['ip_id'].'"> CLICK TO REPORT</a>
That script, in it's entirety, is:
// filtering
$find = strtoupper($find);
$find = strip_tags($find);
$find = trim ($find);
$x = split("\.",$find);
$find = (256*256*256*$x[0]) + (256*256*$x[1]) + (256*$x[2]) + ($x[3]);
// search for term
$s = long2ip($sip);
$e = long2ip($eip);
echo'
<body>
<!-- MAIN TABLE BEGIN-->
<table align="left" width="98%" border="0" cellpadding="0" cellspacing="0">
<tr class="C1">';
include ("inc/image_header.php");
echo'
</tr>
<tr>
<td class="C1" width="150px" valign="top">
<!-- EMBEDDED LEFT TABLE -->';
include ("inc/left_menu.php");
echo'
<!-- END EMBEDDED LEFT TABLE -->
</td>
<td width="530px" valign="top" bgcolor="white">
<!-- EMBEDDED CENTER TABLE -->
<table width="100%" align="center">
<tr>
<td>
<!-- EMBEDDED UPPER SUB-TABLE -->
<table width="100%">
<tr>
<td width="30%"><b><center>Search Again!</center></b></td>
<td width="70%"><form name="search" method="post" action="ip_search.php">
<input type="text" name="find" />
<input type="hidden" name="searching" value="yes" />
<input type="submit" name="search" value="Search" />
</form></td>
</tr>
</table>
<!-- END EMBEDDED UPPER SUB-TABLE -->
</td>
</tr>
<tr>
<td>
<!-- EMBEDDED CENTER SUB-TABLE -->';
if ($searching =="yes")
{
echo'
<table width="100%"><br /><br /><br />
<tr>
<td width="25%"><b>IP Searched For:</b></td>
<td width="75%">'.long2ip($find).'</td>
</tr>
</table>
<!-- END EMBEDDED CENTER SUB-TABLE -->
</td>
</tr>
<tr>
<td>
<!-- EMBEDDED LOWER SUB-TABLE -->';
//If they did not enter a search term we give them an error
if ($find == "")
{
echo'
<table width="100%">
<tr>
<td><center>You forgot to enter a search term</center></td>
</tr>
</table></td>
</tr>
</table>
<!-- END EMBEDDED CENTER TABLE -->
</td>
<td width="120px" valign="top">
<!-- EMBEDDED RIGHT TABLE -->';
include ("inc/ad.php");
echo'
<!-- END EMBEDDED RIGHT TABLE -->
</td>
</tr>';
include ("inc/footer.php");
echo'
</table>
<!-- END MAIN TABLE -->
</body>
</html>';
exit;
}
$query = "SELECT ips.sip, ips.eip, ips.nic, ips.updated, ips.company_id, company.company_id, company.company, company.address1, company.address2, company.zip, company.contact, company.phone, company.e1, company.e2, company.e_ver, company.notes, company.city_id, city.city_id, city.city, company.state_id, state.state_id, state.state, company.country_id, country.country_id, country.country FROM ips, company, city, country LEFT JOIN state ON company.state_id = state.state_id WHERE company.country_id = country.country_id AND company.city_id = city.city_id AND ips.company_id = company.company_id AND sip < '$find' AND eip > '$find'"; // exactly like this
$data = mysql_query($query) or die("Error: ". mysql_error(). " with query ". $query); // explain what's wrong
// display the results
while($result = mysql_fetch_array( $data ))
{
echo "<br>";
}
// counts the number or results
$anymatches=mysql_num_rows($data);
if ($anymatches == 0)
{
$date=date('D M j Y G:i:s');
$sqlquery = "INSERT INTO todo VALUES('','$find', '$date')";
$queryresult = mysql_query($sqlquery) or die(" Could not execute mysql query !");
echo'
<table width="100%">
<tr>
<td><center>The IP Address you entered was not found </center></td>
</tr>
</table>';
} else {
}
}
$query = "SELECT ips.ip_id, ips.sip, ips.eip, ips.nic, ips.updated, ips.company_id, company.company_id, company.company, company.notes, company.address1, company.address2, company.zip, company.contact, company.phone, company.e1, company.e2, company.e_ver, company.city_id, city.city_id, city.city, company.state_id, state.state_id, state.state, company.country_id, country.country_id, country.country FROM ips, company, city, country LEFT JOIN state ON company.state_id = state.state_id WHERE company.country_id = country.country_id AND company.city_id = city.city_id AND ips.company_id = company.company_id AND sip < '$find' AND eip > '$find'"; // exactly like this
$result = mysql_query($query);
$row = mysql_fetch_array($result);
echo'
<br>
<table width="100%">
<tr>
<td class="selcol1" width="25%"><b>Company:</b></td>
<td class="selcol2" width="75%">'.$row['company'].'</td>
</tr>';
if (!empty($row['address1'])) {
echo '<tr>
<td class="selcol1" valign="top"><b>Address:</b></td>
<td class="selcol2">'.$row['address1'].'</td>
</tr>';
} else {
echo '<tr>
<td class="selcol1" valign="top"><b>Address:</b></td>
<td class="selcol2"></td>
</tr>';
}
if (!empty($row['address2'])) {
echo '<tr>
<td> </td>
<td class="selcol2">'.$row['address2'].'</td>
</tr>';
} else {
}
if (!empty($row['city'])) {
echo '<tr>
<td> </td>
<td class="selcol2">'.$row['city'].'';
} else {
}
if (!empty($row['state'])) {
echo ', '.$row['state'].'';
} else {
}
if (!empty($row['zip'])) {
echo ' '.$row['zip'].'</td>
</tr>';
} else {
}
if (!empty($row['country'])) {
echo '<tr>
<td> </td>
<td class="selcol2">'.$row['country'].'</td>
</tr>';
} else {
}
echo'</td>
</tr>
<tr>
<td class="selcol1"><b>Contact:</b></td>
<td class="selcol2">'.$row['contact'].'</td>
</tr>
<tr>
<td class="selcol1"><b>Phone:</b></td>
<td class="selcol2">'.$row['phone'].'</td>
</tr>
<tr>
<td class="selcol1"><b>Email:</b></td>
<td class="selcol2"><b><font color="red">'.$row['e1'].'</font></b></td>
</tr>
<tr>
<td class="selcol1"><b>Alternate Email:</b></td>
<td class="selcol2"><b><font color="red">'.$row['e2'].'</font></b></td>
</tr>
<tr>
<td class="selcol1"><b>Email Verified:</b></td>
<td class="selcol2">'.$row['e_ver'].'</td>
</tr>
<tr>
<td class="selcol1"><b>Date Updated:</b></td>
<td class="selcol2">'.$row['updated'].'</td>
</tr>
<tr>
<td class="selcol1" valign="top"><b>Site Notes:</b></td>
<td class="selcol2"><i>'.$row['notes'].'</i></td>
</tr>
<tr>
<td colspan="2"><center><br /><a class="style1" href="ip_rec.php?ip_id='.$row['ip_id'].'"> CLICK TO REPORT</a></td>
</tr>
</table>
';echo'
<!-- END EMBEDDED LOWER SUB-TABLE -->
</td>
</tr>
</table>
<!-- END EMBEDDED CENTER TABLE -->
</td>
<!-- EMBEDDED RIGHT TABLE -->
';
include ("inc/ad.php");
echo'
<!-- END EMBEDDED RIGHT TABLE -->
</td>
</tr>';
include ("inc/footer.php");
echo'
</table>
<!-- END MAIN TABLE -->
</body>
</html> ';
?>
I am unsure if it is the preceding script which is causing the db to increment by more than one, or if it is a problem with the way I have coded the script which does the incrementing. I'd be more than happy to provide the db structures if that would help!
Thank you.