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

  • Home
  • SEARCH
  • 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 8845933
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:51:11+00:00 2026-06-14T11:51:11+00:00

Here is my query in PHP what I would like to Do IF RATE

  • 0

Here is my query in PHP what I would like to Do IF RATE field IS NULL then Records may not be insert in my MYSQL table. My query doesn’t work here.it’s says check syntax near WHERE. IT’s works fine with out where.I have PHPMYADMIN.

$sql = "INSERT INTO `order`(`po_number`, `vendor_name`, `market`, `start_date`, `end_date`, `qty`, `rate`, `comment`, `media_type`, `sub_vendor`) VALUES ('$po_number1[$i]','$master_vendor1[$i]','$market1[$i]','$start_date1[$i]','$end_date1[$i]','$qty1[$i]','$rate1[$i]','$comment1[$i]','$media_type1[$i]','$sub_vendor1[$i]') WHERE `rate` IS NOT NULL";

Any help Will be appreciate.
Thank You.

  • 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-14T11:51:12+00:00Added an answer on June 14, 2026 at 11:51 am

    You can’t have a WHERE clause on an INSERT INTO query like that. You will have to do any conditional logic prior to the executing the insert query. An insert query adds a new row, therefore by definition there would be no row to evaluate a WHERE clause against. Are you wanting an UPDATE query?

    $errors = array(); // declare this before your loop
    
    if($rate1[$i] == 0 || $rate1[$i] == null)
    {
        // rate is 0 or null, add error
        $errors[] = 'Rate is invalid';
    }
    else
    {
        $sql = "INSERT INTO `order`(`po_number`, `vendor_name`, `market`, `start_date`, `end_date`, `qty`, `rate`, `comment`, `media_type`, `sub_vendor`) VALUES ('$po_number1[$i]','$master_vendor1[$i]','$market1[$i]','$start_date1[$i]','$end_date1[$i]','$qty1[$i]','$rate1[$i]','$comment1[$i]','$media_type1[$i]','$sub_vendor1[$i]')";
        // execute $sql
    }
    

    After completing the loop you can display any errors:

    <ul>
        <?php foreach($errors as $e): ?>
        <li><?php echo $e; ?></li>
        <?php endforeach; ?>
    </ul>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am passing a query variable in PHP. I would like to make it
I would like to insert my ajax query result into a textbox. When user
So I am doing this query from PHP, and here listerally the exact query
Here is my query (I replaced table names with generic ones). I am trying
Here's my query SELECT * FROM wp_postmeta WHERE meta_value LIKE '.$_POST['username'].' AND meta_value LIKE
Here is my query Select Gender from Table The result pane shows 1 1
I have a specific case here in which I would like some security advice.
I would like to add results into array and print on screen. Here's my
I would like to upload a file from android device to server using php.
Trying to learning some more PHP. Here is what I'm after. Essentially, I would

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.