View Full Version : Newbie need your help

02-12-2006, 07:42 PM
Newbie need your help
Can you please tell me what's wrong with this code)

$result = query("SELECT Bloom_Name FROM ihs WHERE Bloom_Name = $Bloom_Name);
if (mysql_num_rows($result) >= 1) {
$error="Cultivar Name Already Used, Please use another Name";
echo $error;
} else {
$insert = $query="insert into ihs (Bloom_Name,Pod_Parent,Pollen_Parent,

02-12-2006, 08:38 PM
First of all, please
use PHP tags when you display PHP code in your forum post....

Are you getting any error messages? Usually they help to pinpoint a problem....

$query = "SELECT Bloom_Name FROM ihs WHERE Bloom_Name='" . $Bloom_Name . "'";
$result = mysql_query($query);
if (mysql_num_rows($result) >= 1)
die("Cultivar Name Already Used, Please use another Name");
$query = "INSERT INTO ihs (Bloom_Name,Pod_Parent,Pollen_Parent) VALUES ('" . $Bloom_Name . "','value2','value3')";
$result = mysql_query($query);
if (mysql_affected_rows() < 1)
die("The table row was not added");

I recommned this site for learning PHP: http://us2.php.net/manual/en/index.php

And this site for learning SQL: http://www.w3schools.com/sql/default.asp

02-12-2006, 08:50 PM
You probably want to put single-quotes around $Bloom_name

02-13-2006, 01:11 AM
my bad...