Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8309095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T19:00:10+00:00 2026-06-08T19:00:10+00:00

This is for a data import script, I want to check if the Category

  • 0

This is for a data import script, I want to check if the Category Name with a Parent ID already exists; if it does then it does not need to be added to the database. My check however is not stopping duplicate entries.

$i = 1;
$check = FALSE;
echo'<br>';
do{
   //Turn import order into Colewood order. 
   $tieroffset = $i - 1;

   $tier = $csvdata[$r][$fields["Tier" . $i]];

   $query = ("SELECT name FROM base_categories WHERE name = '".$tier."' AND id = '".$tieroffset."'");
   $result = mysql_query($query);
   $result_array = mysql_fetch_array($result);

   if (empty($result_array)) {

       if($tier != null){ 
       $queryInsert = "INSERT INTO base_categories (parent_id,name) 
                        VALUES ('" . $tieroffset . "', '" . mysql_real_escape_string($csvdata[$r][$fields["Tier" . $i]]) . "')";
       }

        mysql_query($queryInsert);

        print_r($queryInsert);
   }                

   $i++;
}while ($i <= 6 || $check != FALSE);
echo'    >>>END PRODUCT<br>';
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T19:00:12+00:00Added an answer on June 8, 2026 at 7:00 pm

    Use mysql_num_rows function to check the number of rows returned by the query.

    if (empty($result_array)) {
    

    to

    if (mysql_num_rows($result) == 0 ) {
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This Python code pipes data through Perl script fine. import subprocess kw = {}
I have a large nested vector that look like this: import Data.Vector let x
This Python: data = {} def f(): pass import sys help(sys.modules[__name__]) Prints this: Help
I just follow this DIHQuickStart , try to import data to solr from mysql.
This is my code for counting lines and words: import System.IO import Data.List main
for this, import os.path def f(data_file_path=os.path.join(os.getcwd(),'temp'),type): ... return data I get this, SyntaxError: non-default
this is html from <form action=http://localhost/own/import.php method=post enctype=multipart/form-data name=form1> <input type=file name=xmlfile id=file1> <input
I have a script like this: #!/Python26/ # -*- coding: utf-8 -*- import sys
Possible Duplicate: Get script of SQL Server data I want to move some rows
I have a very basic python script that does HTTP connection. import socket def

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.