Avatar of michael789
michael789

asked on 

Insert Blank Record into MySQL after query

Hi:

I have a search page that gives an array of results to the next page where I filter the specific table for results. However each time I am on this page it will insert a blank record into the "products" table.

Any ideas why this could be? There is no insert record in this page?

$currentPage = $_SERVER["PHP_SELF"];
$maxRows_products = 12;
$pageNum_products = 0;
if (isset($_GET['pageNum_products'])) {
  $pageNum_products = $_GET['pageNum_products'];
}
$startRow_products = $pageNum_products * $maxRows_products;
 
if(!isset($_GET['tradeshow']))
  $keyword_sql = '1=1'; # dummy condition when there are no keyword parameter
elseif(is_array($_GET['tradeshow'])) { # array keyword parameter
  $keyword_sql = array();
  foreach($_GET['tradeshow'] as $kw) {
    $kw = mysql_real_escape_string($kw);
    $keyword_sql[] = "tradeshows.showname LIKE '%$kw%'";
  }
  $keyword_sql = '('.implode(' or ',$keyword_sql).')';
} else { # single keyword parameter
  $kw = mysql_real_escape_string($_GET['keyword']);
  $keyword_sql = "tradeshows.showname LIKE '%$kw%'";
}
 
mysql_select_db($database_inburn, $inburn);
$query_products = "SELECT * FROM products_trade
LEFT JOIN products ON products.id = products_trade.ID_product_trade
LEFT JOIN tradeshows ON tradeshows.id_show = products_trade.tradeshowID 
WHERE $keyword_sql
GROUP BY products_trade.ID_product_trade";
$products = mysql_query($query_products, $inburn) or die(mysql_error());
$row_products = mysql_fetch_assoc($products);
$totalRows_products = mysql_num_rows($products);

Open in new window

PHP

Avatar of undefined
Last Comment
michael789
Avatar of djberriman
djberriman

That code can't cause an insert. Something else is causing it. If it is that page then the only thing I can think of is a database trigger.
Avatar of michael789
michael789

ASKER

i know...that's why it is so weird...thank you for your response. Here the entire page. I don't see anything else that could trigger the insert!
index-results-tradeshow.txt
ASKER CERTIFIED SOLUTION
Avatar of djberriman
djberriman

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of michael789
michael789

ASKER

i found the error to be in a trigger related to an ajax rating...it is really weird because it had nothing to do with the actual page. Thank you for your help
PHP
PHP

PHP is a widely-used server-side scripting language especially suited for web development, powering tens of millions of sites from Facebook to personal WordPress blogs. PHP is often paired with the MySQL relational database, but includes support for most other mainstream databases. By utilizing different Server APIs, PHP can work on many different web servers as a server-side scripting language.

125K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo