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 6895917
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:58:11+00:00 2026-05-27T06:58:11+00:00

I am importing an excel file to DB. For that i am using excel-class

  • 0

I am importing an excel file to DB. For that i am using excel-class reader. Using that i can insert values to DB directly. Here is my code to insert data.

$q="SELECT * FROM leads_info WHERE  name='".$rows[1]."' AND home_phone='".$rows[2]."' AND mobile_phone='".$rows[3]."'  AND address='".$rows[4]."' AND suburb='".$rows[5]."' AND postcode='".$rows[6]."'";
$r= mysql_query($q) or die(mysql_error());
$row = mysql_fetch_array($r);
if(empty($row))
     {
$sql = "INSERT INTO leads_info VALUES('','$rows[1]','$rows[2]','$rows[3]','$rows[4]','$rows[5]','$rows[6]')";
$result=mysql_query($sql) or die(mysql_error());
     } 

Actually this insertion is in a loop. That loop is inserting each row of an excel file.Before inserting the data, selecting all the duplicates from DB and stored it in an array(ie:$row). If $row is empty($row doesn’t have the excel row), inserting the data.But it didn’t work.

  • 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-05-27T06:58:12+00:00Added an answer on May 27, 2026 at 6:58 am

    Instead of:

    $row = mysql_fetch_array($r);
    if(empty($row))
    

    do:

    if(!mysql_num_rows($r))
    

    BTW, you have some SQL injection issues there. (Google that to learn more about it.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm importing data from a CSV file that comes from excel, but i can't
I'm importing data from an excel file and I just noticed that some cells
I am importing massive amounts of data from Excel that have various table layouts.
I'm importing some data from a CSV file, and numbers that are larger than
Can You Import an Excel File to a MySQL Database using phpMyAdmin? I am
I'm importing data from an Excel sheet on to a DataTable using the following
I had used JExcel API for importing Data's from Excel,for using JExcel , I
I'm looking for the best method for importing csv or excel file to SQL
I am importing csv to db using bulk insert. It is the comma delimited
I need to make an excel file which would fetch data from connection to

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.