jeff5656 Posted June 10, 2009 Share Posted June 10, 2009 I get: Invalid query: Unknown column 'f2a' in 'where clause' but the table "rounder" does contain a column called service tht contains "f2a" in one of the records, so why doesn't this work? <?php $service = $_POST['service']; $sql = "UPDATE rounder SET staff_name = '" . $_POST['staff_name'] . "' WHERE service = ".$_POST['service'].""; if (isset($sql) && !empty($sql)) { $result = mysql_query($sql) or die ("Invalid query: " . mysql_error()); ?> here's my rounder table that I got from phpmyadmin: CREATE TABLE `rounder` ( `id_incr` int(254) NOT NULL auto_increment, `service` varchar(10) NOT NULL, `staff_name` varchar(20) NOT NULL, PRIMARY KEY (`id_incr`), UNIQUE KEY `service` (`service`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ; -- -- Dumping data for table `rounder` -- INSERT INTO `rounder` (`id_incr`, `service`, `staff_name`) VALUES (1, 'f2a', 'jennings'), (2, 'f2b', 'stagner'); Link to comment https://forums.phpfreaks.com/topic/161739-solved-invalid-query/ Share on other sites More sharing options...
J.Daniels Posted June 10, 2009 Share Posted June 10, 2009 Try adding quotes around $_POST['service'] $sql = "UPDATE rounder SET staff_name = '" . $_POST['staff_name'] . "' WHERE service = '".$_POST['service']."'"; Link to comment https://forums.phpfreaks.com/topic/161739-solved-invalid-query/#findComment-853363 Share on other sites More sharing options...
jeff5656 Posted June 10, 2009 Author Share Posted June 10, 2009 thanks that worked. Link to comment https://forums.phpfreaks.com/topic/161739-solved-invalid-query/#findComment-853366 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.