PHP Problem...
Posted: Sat Mar 07, 2009 3:06 pm
Hi all,
i am trying to check my database to see if someone hass already submitted a particular team name. so i have set up the if statment but it always returns the following:(the database is empty FYI)
0ROW EXSISTS
i thought by my code that im sating if the row is = to 0 run thi code.. if it no. display this message.,....
can anyone point me in the right direction? below is the full code of that page
<?
$Count = mysql_query("SELECT COUNT(*) FROM `group` WHERE `teamname` = '$TeamName'");
$row = mysql_fetch_array($Count, MYSQL_NUM);
echo $row[0];
if ($row=="0")
{
$sql=("INSERT INTO `group`(teamname, nickname, stadiumname, stadiumcapacity, country, league, rivalclub, town, website)
VALUES ('$TeamName', '$NickName', '$StadiumName', '$StadiumCapacity', '$country','$league', '$RivalClub', '$town', '$website')") or die(mysql_error());
}
else if ($row>"0")
{ echo "ROW EXSISTS"; }
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
?>
i am trying to check my database to see if someone hass already submitted a particular team name. so i have set up the if statment but it always returns the following:(the database is empty FYI)
0ROW EXSISTS
i thought by my code that im sating if the row is = to 0 run thi code.. if it no. display this message.,....
can anyone point me in the right direction? below is the full code of that page
<?
$Count = mysql_query("SELECT COUNT(*) FROM `group` WHERE `teamname` = '$TeamName'");
$row = mysql_fetch_array($Count, MYSQL_NUM);
echo $row[0];
if ($row=="0")
{
$sql=("INSERT INTO `group`(teamname, nickname, stadiumname, stadiumcapacity, country, league, rivalclub, town, website)
VALUES ('$TeamName', '$NickName', '$StadiumName', '$StadiumCapacity', '$country','$league', '$RivalClub', '$town', '$website')") or die(mysql_error());
}
else if ($row>"0")
{ echo "ROW EXSISTS"; }
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
?>