Hamlets666 Posted January 26, 2007 Share Posted January 26, 2007 Hie ;)[code]$ins = "INSERT INTO msg(to, txt, type)values('$cid', '$newtxts', '1')";[/code]Error :[i]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'to, txt, type)values('1', 'Building motorfactoryRUS is done', '1[/i]When I "print" query it look`s so : [i]INSERT INTO msg(to, txt, type)values('1', 'Building motorfactoryRUS is done', '1')[/i]Can`t get a point what`s wrong... Quote Link to comment https://forums.phpfreaks.com/topic/35793-mysql-error/ Share on other sites More sharing options...
gazalec Posted January 26, 2007 Share Posted January 26, 2007 have u checked your table field are the correct format i.e not letters going into a numeric field etc., and also just to check the field length of 'txt' field Quote Link to comment https://forums.phpfreaks.com/topic/35793-mysql-error/#findComment-169641 Share on other sites More sharing options...
Hamlets666 Posted January 26, 2007 Author Share Posted January 26, 2007 [b]to[/b] is BIGINT, [b]txt[/b] - TEXT, [b]type[/b] is TEXTLook`s ok for me! Quote Link to comment https://forums.phpfreaks.com/topic/35793-mysql-error/#findComment-169644 Share on other sites More sharing options...
gazalec Posted January 26, 2007 Share Posted January 26, 2007 wot is the field length on the txt field? Quote Link to comment https://forums.phpfreaks.com/topic/35793-mysql-error/#findComment-169647 Share on other sites More sharing options...
Cep Posted January 26, 2007 Share Posted January 26, 2007 I know this is a problem with Access databases but maybe its true of MySQL as well but are you certain that your field name in your table match exactly the same names as those in your SQL statement, it may well be you have called txt in your statement when the field name is TXT or Txt.Also space out your query,[code]$ins = "INSERT INTO msg (to, txt, type) VALUES ('$cid', '$newtxts', '1')";[/code]And if to is a bigint you do not need to have quotes around it. Quote Link to comment https://forums.phpfreaks.com/topic/35793-mysql-error/#findComment-169650 Share on other sites More sharing options...
HuggieBear Posted January 26, 2007 Share Posted January 26, 2007 The problem is that you're using [url=http://dev.mysql.com/doc/refman/4.1/en/reserved-words.html]reserved words[/url] in your statement. You can't use [b]to[/b] without quoting it with backticks (`), as it's a reserved word in MySQL...Try this:[code]<?php$ins = "INSERT INTO msg (`to`, `txt`, `type`) VALUES ($cid, '$newtxts', '1')";?>[/code]RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/35793-mysql-error/#findComment-169683 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.