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());
mysql insertion problem!!
Moderator: General Moderators
-
pavanesh2009
- Forum Commoner
- Posts: 30
- Joined: Wed Jan 13, 2010 7:24 am
- Grizzzzzzzzzz
- Forum Contributor
- Posts: 125
- Joined: Wed Sep 02, 2009 8:51 am
Re: mysql insertion problem!!
missing quotation marks within your POSTS?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());
eg:
Code: Select all
$_POST[species_master1]
Code: Select all
$_POST["species_master1"]
-
pavanesh2009
- Forum Commoner
- Posts: 30
- Joined: Wed Jan 13, 2010 7:24 am
Re: mysql insertion problem!!
Thank you vey much for your kind help!!
Grizzzzzzzzzz wrote:missing quotation marks within your POSTS?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());
eg:should beCode: Select all
$_POST[species_master1]Code: Select all
$_POST["species_master1"]