Page 1 of 1

mysql insertion problem!!

Posted: Wed Jan 20, 2010 8:31 am
by pavanesh2009
Hello All,
I am getting value from a form & trying to insert it into database table called 'trees'.
everthing working fine except species_id into trees table.I am getting warning:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /var/www/seasonwatch/tracktrees.php on line 14

Please suggest what mistake i am doing?
Thanks in Advance!!

$specresult = mysql_query("SELECT * FROM Species_master WHERE species_id=".$_POST[species_master1].";");
while ($specdata = mysql_fetch_array($specresult))
{
}
$sql1 = "INSERT INTO trees
(tree_desc,is_fertilised,
is_watered,species_id,tree_location_id)
VALUES
('$_POST[tree_desc]',
'$_POST[is_fertilized]',
'$_POST[is_watered]',
'$specdata',
'$_POST[tree_location_id]'
)";
mysql_query($sql1,$link)or die("Insertion Failed:" .mysql_error());

Re: mysql insertion problem!!

Posted: Wed Jan 20, 2010 8:46 am
by Grizzzzzzzzzz
pavanesh2009 wrote:Hello All,
I am getting value from a form & trying to insert it into database table called 'trees'.
everthing working fine except species_id into trees table.I am getting warning:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /var/www/seasonwatch/tracktrees.php on line 14

Please suggest what mistake i am doing?
Thanks in Advance!!

$specresult = mysql_query("SELECT * FROM Species_master WHERE species_id=".$_POST[species_master1].";");
while ($specdata = mysql_fetch_array($specresult))
{
}
$sql1 = "INSERT INTO trees
(tree_desc,is_fertilised,
is_watered,species_id,tree_location_id)
VALUES
('$_POST[tree_desc]',
'$_POST[is_fertilized]',
'$_POST[is_watered]',
'$specdata',
'$_POST[tree_location_id]'
)";
mysql_query($sql1,$link)or die("Insertion Failed:" .mysql_error());
missing quotation marks within your POSTS?

eg:

Code: Select all

 
$_POST[species_master1] 
 
should be

Code: Select all

 
$_POST["species_master1"]
 

Re: mysql insertion problem!!

Posted: Thu Jan 21, 2010 12:28 am
by pavanesh2009
Thank you vey much for your kind help!!

Grizzzzzzzzzz wrote:
pavanesh2009 wrote:Hello All,
I am getting value from a form & trying to insert it into database table called 'trees'.
everthing working fine except species_id into trees table.I am getting warning:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /var/www/seasonwatch/tracktrees.php on line 14

Please suggest what mistake i am doing?
Thanks in Advance!!

$specresult = mysql_query("SELECT * FROM Species_master WHERE species_id=".$_POST[species_master1].";");
while ($specdata = mysql_fetch_array($specresult))
{
}
$sql1 = "INSERT INTO trees
(tree_desc,is_fertilised,
is_watered,species_id,tree_location_id)
VALUES
('$_POST[tree_desc]',
'$_POST[is_fertilized]',
'$_POST[is_watered]',
'$specdata',
'$_POST[tree_location_id]'
)";
mysql_query($sql1,$link)or die("Insertion Failed:" .mysql_error());
missing quotation marks within your POSTS?

eg:

Code: Select all

 
$_POST[species_master1] 
 
should be

Code: Select all

 
$_POST["species_master1"]