...

View Full Version : Newbie need your help



jdimino
02-12-2006, 06: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,

chump2877
02-12-2006, 07: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");
}
else
{
$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

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

chump2877
02-13-2006, 12:11 AM
my bad...



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum