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>";
}
try mysql_num_rows() instead of mysql_affected_rows.
code like this.
then