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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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