That was my initial thought. I normally use the variable $query to hold the MySQL query and I thought there may be another mysql_query statement somewhere in the rest of the code that was throwing the second insert; so, I changed the variable name to $searches which is used nowhere else in the entire website. The entire code for search.php is nearly 500 lines long as it is a site search. Here is the beginning:
Code: Select all
session_start();
$replace = array("'", "\"", ">", "<", "(", ")", ":", ";", "[", "]", "/", "\\", "=", "+", "@", "%", "$", "&", "*", "^", "-");
$search = str_replace($replace, "", $_GET['term']);
if ($search == "")
$search = "Blogs";
include './Login/VerifySession.php';
include './loginbox.php';
$search = strtolower($search);
$keywords = preg_split("/[\s,]+/", $search);
$numwords = count($keywords);
$link = mysql_connect('*******', '*******', '*******')
or die('Could not connect: ' . mysql_error());
mysql_select_db('*********') or die('Could not select database');
$searches = "INSERT INTO searchqueries (term, user) VALUES ('".$search."', '".$un."')";
mysql_query($searches) or die('Query failed: ' .mysql_error());
mysql_close($link);
The rest of the code performs the search and is fairly long...
In case you were wondering, $un is defined within /Login/VerifySession.php
Thanks for the reply!