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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:45:20+00:00 2026-06-03T07:45:20+00:00

Using this syntax I can add records in the fields but it always add

  • 0

Using this syntax I can add records in the fields but it always add 2 records. For example I input Ana as a name. The output would be 2 Ana. And if ever I delete one record, both records were deleted/ removed from the table. Here is the syntax for adding the record:

    <?php
$host="localhost"; // Host name 
$username="****"; // Mysql username 
$password="****"; // Mysql password 
$db_name="inventory"; // Database name 
$tbl_name="client"; // Table name

mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");


$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
mysql_select_db("inventory", $con);


$addclient="INSERT INTO client(account_name, maintenance_type, ma_status, ma_contract_start, ma_contract_end, ma_reference_no) 
VALUES ('". $_POST['account_name'] . "', '". $_POST['maintenance_type'] . "', '". $_POST['ma_status'] . "', '". $_POST['ma_contract_start'] . "', '". $_POST['ma_contract_end'] . "', '". $_POST['ma_reference_no'] . "')";

mysql_query($addclient,$con);

if (!mysql_query($addclient,$con))
  {
  die('Error: ' . mysql_error());
  }
echo "1 record added";

mysql_close($con);
  • 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-03T07:45:22+00:00Added an answer on June 3, 2026 at 7:45 am
    ...
    mysql_query($addclient,$con);
    
    if (!mysql_query($addclient,$con)) {
    ...
    

    The first call to ‘mysql_query’ executes the command once.
    The second one in the ‘if’ clause, does the query again.

    Try this:

    ...
    $result = mysql_query($addclient,$con);
    
    if (!$result) {
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using the C# object initializer syntax I can instantiate an anonymous object like this:
What's the point using this syntax div.card > div.name What's the difference between this
i am using this code <a onclick=javascript:var t=setInterval(GetUpdates(5,ajaxResult),300);>GetUpdates</a> but getting the syntax error
I'm using sqlite3 and this would be pretty easy if it supported TOP syntax
What's the difference between reading a value from an SqlDataReader using this syntax: Dim
I've embedded a SWF into a class using this syntax above my class definition:
Lets say you are using the if syntax for Ruby that goes like this:
Using this: Can I use Facebook's fb:friend-selector in an iframe? I created a multi-friend
This should be a softball for you SQL guys. I know I can add
I am using Delphi, but this is a simple and general problem: I'm doing

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.