Jump to content

Mysql Error


Hamlets666

Recommended Posts

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...

Link to comment
https://forums.phpfreaks.com/topic/35793-mysql-error/
Share on other sites

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.
Link to comment
https://forums.phpfreaks.com/topic/35793-mysql-error/#findComment-169650
Share on other sites

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]

Regards
Huggie
Link to comment
https://forums.phpfreaks.com/topic/35793-mysql-error/#findComment-169683
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.