I am sorry, my error message was not clear.

The following is an error message..
> Statement:
> Syntax error or access violation: You have an error in your SQL syntax
near
> 'xxxxxxxxxxxxxxxxxxx","ccccccccccccccccccccccccc","-1","-1",")' at line 1

I was simply writing a sting into a database field. The field was logMessage
in the following table.

mysql> explain applog
    -> ;
+------------+---------------+------+-----+---------+----------------+
| Field      | Type          | Null | Key | Default | Extra          |
+------------+---------------+------+-----+---------+----------------+
| applogid   | int(10)       |      | PRI | NULL    | auto_increment |
| logMessage | varchar(255)  | YES  |     | NULL    |                |
| timedate   | timestamp(14) | YES  |     | NULL    |                |
+------------+---------------+------+-----+---------+----------------+

The string written was compiled from the following code:

query = "INSERT INTO passtbl(user,pass,employeeId,customerId) VALUES";
          query += "(\"" + this.getuserId() + "\",";
          query += "\"" + this.getpass() + "\",";
          query += "\"" + this.employeeId + "\",";
          query += "\"" + this.customerId + "\",";

The string was an Insert statment which mySql acted upon. It should have
just written the string into the
logMessage field.

The table below which is being used to log transactions, shows that select
statments can be written into the
message field. Insert statments cannot.

mysql> select * from applog;
+----------+----------------------------------------------------------------
----
--------------------------------------------------------+----------------+
| applogid | logMessage
                                                        | timedate       |
+----------+----------------------------------------------------------------
----
--------------------------------------------------------+----------------+
|        1 | checkUser
                                                        | 20010221092931 |
|        2 | updateCustomer
                                                        | 20010221093150 |
|        3 | checkUser
                                                        | 20010221093408 |
|        4 | checkUser
                                                        | 20010221093423 |
|        5 | updateCustomer
                                                        | 20010221093501 |
|        6 | checkUser
                                                        | 20010221094134 |
|        7 | updateCustomer
                                                        | 20010221094152 |
|        8 | updatePage3
                                                        | 20010221094359 |
|        9 | updatePasstbl
                                                        | 20010221094359 |
|       10 | Syntax error or access violation: You have an error in your SQL
syn
tax near '' at line 1                                   | 20010221094359 |
|       11 | checkUser
                                                        | 20010221100001 |
|       12 | 564: Select * from passtbl Where user ='sssssssssssssssss'
                                                        | 20010221100001 |
|       13 | updateCustomer
                                                        | 20010221100018 |
|       14 | checkUser
                                                        | 20010221100437 |
|       15 | 564: Select * from passtbl Where user ='xxxxxxxxxxxxxxxxxxx'
                                                        | 20010221100437 |
|       16 | updateCustomer
                                                        | 20010221100455 |
|       17 | checkUser
                                                        | 20010221100632 |
|       18 | 564: Select * from passtbl Where user ='xxxxxxxxxxxxxxxxxx'
                                                        | 20010221100639 |
|       19 | checkUser
                                                        | 20010221101121 |
|       20 | 564: Select * from passtbl Where user ='kjlkjlkjlkjl'
                                                        | 20010221101121 |
|       21 | updatePage3
                                                        | 20010221101224 |
|       22 | updatePasstbl
                                                        | 20010221101224 |
|       23 | Syntax error or access violation: You have an error in your SQL
syn
tax near '' at line 1                                   | 20010221101224 |
|       24 | checkUser
                                                        | 20010221101530 |
|       25 | 564: Select * from passtbl Where user ='lkjlkjlkjllkjlkj'
                                                        | 20010221101530 |
|       26 | updatePage3
                                                        | 20010221101652 |
|       27 | updatePasstbl
                                                        | 20010221101652 |
|       28 | checkUser
                                                        | 20010221102255 |
|       29 | 564: Select * from passtbl Where user ='XXXXXXXXXXXXXX'
                                                        | 20010221102255 |
|       30 | updatePage3
                                                        | 20010221102418 |
|       31 | updatePasstbl 789
                                                        | 20010221102418 |
|       32 | updatePasstbl 808
                                                        | 20010221102418 |
|       33 | checkUser
                                                        | 20010221102622 |
|       34 | 564: Select * from passtbl Where user ='DDDDDDDDDDDDDDDDD'
                                                        | 20010221102622 |
|       35 | updatePage3
                                                        | 20010221102715 |
|       36 | updatePasstbl 789
                                                        | 20010221102715 |
|       37 | updatePasstbl 808
                                                        | 20010221102715 |
|       38 | updatePasstbl 803
                                                        | 20010221102715 |
|       39 | checkUser
                                                        | 20010221103113 |
|       40 | 564: Select * from passtbl Where user ='SSSSSSSSSSSSSSSSS'
                                                        | 20010221103117 |
|       41 | checkUser
                                                        | 20010221103256 |
|       42 | 564: Select * from passtbl Where user ='xxxxxxxxxxxxxxxxxxx'
                                                        | 20010221103256 |
|       43 | updatePage3
                                                        | 20010221103403 |
|       44 | updatePasstbl 789
                                                        | 20010221103404 |
|       45 | updatePasstbl 808
                                                        | 20010221103404 |
|       46 | updatePasstbl 803
                                                        | 20010221103411 |
|       47 | checkUser<checkUser>
                                                        | 20010221105928 |
|       48 | 564: Select * from passtbl Where user
='sssssssssssssssssss'<564: S
elect * from passtbl Where user ='sssssssssssssssssss'> | 20010221105929 |
|       49 | updatePage3<updatePage3>
                                                        | 20010221110030 |
|       50 | updatePasstbl 789<updatePasstbl 789>
                                                        | 20010221110030 |
|       51 | updatePasstbl 808<updatePasstbl 808>
                                                        | 20010221110030 |
|       52 | updatePasstbl 803<updatePasstbl 803>
                                                        | 20010221110030 |
+----------+----------------------------------------------------------------
----
--------------------------------------------------------+----------------+
52 rows in set (0.11 sec)



Thanks for the very quick response.

a.l.


-----Original Message-----
From: Atle Veka [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, February 21, 2001 11:38 AM
To: allen2k
Cc: [EMAIL PROTECTED]
Subject: Re: Error when writing a sql statement into a field.


On Wed, 21 Feb 2001, allen2k wrote:

>
> Statement:
> Syntax error or access violation: You have an error in your SQL syntax
near
> 'xxxxxxxxxxxxxxxxxxx","ccccccccccccccccccccccccc","-1","-1",")' at line 1
>
>
> Was updating a log table in the database that has a message field. The
message field was
> being updataed with:
>
>
>         query = "INSERT INTO passtbl(user,pass,employeeId,customerId)
VALUES";
>           query += "(\"" + this.getuserId() + "\",";
>           query += "\"" + this.getpass() + "\",";
>           query += "\"" + this.employeeId + "\",";
>           query += "\"" + this.customerId + "\",";

drop the last comma, and add a close paranthesis. if you haven't
already. also, you can use single quotes to separate values..


Atle


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to