Okay. I have a players table layed out as follows:
PLAYERID (autoincrement)
Lastname
Firstname
address
city
state
zip
I want to add a player, but ensure the player does not exist under a different id. I have the following coded:
$con= mysql_connect($host,$usrnm,$passwrd)
or die("Connection failed!!! <br>");
$varselect=mysql_select_db($database)
or die("Database selection failed!!!");
$query = mysql_query("SELECT lastname, firstname FROM players WHERE
lastname = $POST[lastname]' AND firstname = '$POST[firstname]'");
$numrows = mysql_num_rows($query);
if ($numrows == 1) {
echo "PERSON EXISTS!.. Don't perform insert.";
}
else
if ($numrows == 0)
{
$query2=mysql_query("INSERT INTO players VALUES('NULL',
'".$lastname."',
'".$firstname."',
'".$address."',
'".$city."',
'".$state."',
'".$zip."',
'".$dob."',
'".$primaryteam."',
'".$secondaryteam."',
'".$sex."',
'".$siblings."',
'".$homephone."',
'".$workphone."',
'".$cellphone."',
'".$email."');");
}
$varquery=mysql_query($query2);
if (!$varquery)
{
die( "Query execution failed!!!<br>" . mysql_error() );
}
else
{ (this here loads into a table stating player added on the screen and shows what was inserted).
However I get an error stating 'Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/reedsbu/public_html/insert_player.php on line 35
Query execution failed!!!'
Any ideas?