anthonydamasco Posted September 8, 2006 Share Posted September 8, 2006 Alright, ive been debbuging this forever does anyone see something wrong in this sql script[code=php:0]$sql = "INSERT INTO jobs VALUES (NULL, '$jobtitle', '$location', '$payrate', '$hours', '$jobdes', '$jobcat' '$branch', '$time', '$poscla', SYSDATE(), '$expire')";mysql_query($sql) or die ( "Problem with the query: $sql<br>" . mysql_error() );[/code]the table looks like thisjobid integerjobtitle varcharlocation varcharpayrate varcharhours varcharjobdescription varcharjobcat varcharbranch varchartime varcharposition varchardate DATEexpire varcharThis is the errorProblem with the query: INSERT INTO jobs VALUES (NULL, 'test', 'test', 'test', 'test', 'test', 'test' 'pennsauken', 'test', 'test', SYSDATE(), '1')ahhh! help! Link to comment https://forums.phpfreaks.com/topic/20157-quick-sql-santax-question/ Share on other sites More sharing options...
HuggieBear Posted September 8, 2006 Share Posted September 8, 2006 I don't know much about MySQL, but why not try...[code]$sql = "INSERT INTO jobs (jobtitle, location, payrate, hours, jobdescription, jobcat, branch, time, position, date, expire) VALUES ('$jobtitle', '$location', '$payrate', '$hours', '$jobdes', '$jobcat' '$branch', '$time', '$poscla', SYSDATE(), '$expire')";mysql_query($sql) or die ( "Problem with the query: $sql<br>" . mysql_error() );[/code]All I've done is specify which columns to explicitly insert into, and dropped your initial column as I assumed it's an autoincrementing primary key. Which is probably where the problem lies if you're trying to insert 'null' into it.Rich Link to comment https://forums.phpfreaks.com/topic/20157-quick-sql-santax-question/#findComment-88638 Share on other sites More sharing options...
anthonydamasco Posted September 8, 2006 Author Share Posted September 8, 2006 that just changed the error :-pProblem with the query: INSERT INTO jobs (jobtitle, location, payrate, hours, jobdescription, jobcatagory, branch, timeneeded, positionclass, date, expire) VALUES ('test', 'test', 'test', 'test', 'test', 'test' 'cherryhill', 'test', 'test', SYSDATE(), '1')Column count doesn't match value count at row 1 Link to comment https://forums.phpfreaks.com/topic/20157-quick-sql-santax-question/#findComment-88641 Share on other sites More sharing options...
HuggieBear Posted September 8, 2006 Share Posted September 8, 2006 oh ok.... I've noticed the problem it's around the date format....[b]sysdate()[/b] will give you a value like [color=green]'0000-00-00 00:00:00'[/color] but you're trying to insert into a [color=red]date[/color] field that looks like this [color=green]'0000-00-00'[/color]So you need to change the [color=red]date[/color] field to [color=red]datetime[/color] or swap [b]sysdate()[/b] for [b]curdate()[/b].RegardsRich Link to comment https://forums.phpfreaks.com/topic/20157-quick-sql-santax-question/#findComment-88649 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.