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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T00:07:54+00:00 2026-06-03T00:07:54+00:00

When a teamname is not in the database I want to enter it if

  • 0

When a teamname is not in the database I want to enter it if not ignore it. But I do not get an error all I see is the echoed statement but it is not entered into the database.
The database is MySQL and table name is 2012FallTeamstats I have a team_id column which is autoincremented a win a loses and a percentages field. (4 total in table)

mysql_query("SELECT teamname FROM 2012FallTeamstats WHERE teamname = '$teamH'"); 
if (mysql_affected_rows() == 0) {
    mysql_query("INSERT INTO 2012FallTeamstats (teamname) VALUES ('$teamH')");
    echo "New: <strong>".stripslashes($teamH)."</strong> (home team) inserted into the database.<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-03T00:07:57+00:00Added an answer on June 3, 2026 at 12:07 am

    try mysql_num_rows() instead of mysql_affected_rows.

    code like this.

    $result_team =  mysql_query(.........); (your code)
    

    then

    if(mysql_num_rows($result_team) == 0)
    {
    //insert command
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to bind TextBlocks to a Modell. But it does not work and
I have a database table full of game by game results and want to
I got the above error though i have set the ID manually, Im not
Database structure: Clubs: ID, ClubName Teams: ID, TeamName, ClubID Players: ID, Name Registrations: PlayerID,
i want to store the colors of a team but unfortunately i am using
I have a many to many table setup in my mysql database. Teams can
I have a many to many table setup in my mysql database. Teams can
Hello I am trying to display the constraints in one of my tables but
I data in the below format (List of HashMap's) {TeamName=India, Name=Sachin, Score=170} {TeamName=India, Name=Sehwag,
A continuation from this question I need a SQL statement that returns the number

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.