954,587 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

php issue with sql update

Hi Guys,

Not sure if this is a php or sql problem but i keep getting the following error when trying to update a row using php and 'UPDATE':

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

I've done a bit of testing on it and when i remove 'description' from the update it works fine.
My 'description' field is 2000 in length so i'm assuming it's too big to handle.
Any suggestions welcome.

Regards,

Tom.

baseballfury
Light Poster
49 posts since Feb 2010
Reputation Points: 10
Solved Threads: 0
 

you should have to use LONGBLOB datatype for your description.

This will help you in update query. and you don't have to define any length in LONGBLOB datatype,

it will work fine and display your description with normal fetch method.

jogesh_p
Junior Poster in Training
68 posts since Sep 2010
Reputation Points: 16
Solved Threads: 6
 

Thanks Jogesh,

Will give it a go as soon as i get home.

baseballfury
Light Poster
49 posts since Feb 2010
Reputation Points: 10
Solved Threads: 0
 

Hi again,

How would i go about saving the update info to a longblob/longtext i.e. what is the syntax.
I've looked for examples without success.
Does it matter that some of the fields are set as varchar in the database?

Thanks,

Tom.

baseballfury
Light Poster
49 posts since Feb 2010
Reputation Points: 10
Solved Threads: 0
 

hi Tom, here is an example for LONGBLOB with syntax

CREATE TABLE `test`.`check` (
`description` LONGBLOB NOT NULL
) ENGINE = InnoDB;


these syntax for LONGTEXT

CREATE TABLE `test`.`check` (
`description` LONGTEXT NOT NULL
) ENGINE = InnoDB;


actually the length of VARCHAR is 0 to 255, it will not display more than 255, and it doesn't matter that other fields are set VARCHAR, cause the database contain any datatype in mean time, like ID as INT, NAME as VARCHAR, and DISCRIPTION as LONGBLOB but the difference is if you want to see the value direct in phpmyadmin the you will not see that LONGBLOB value, just see its size in bytes and i don't think so its a huge matter to see in phpmyadmin.

hopefully it help you to understand :)

take care

jogesh_p
Junior Poster in Training
68 posts since Sep 2010
Reputation Points: 16
Solved Threads: 6
 

Thanks for the detailing there Jogesh.
I was working on it last night and something didn't seem quite right and then i realised i'd been using reserved names for my column names more specifically 'desc'....duh.

Thanks for the explaination about blobs though my resulting investigation has gained me alot of knowledge about them

Tom.

baseballfury
Light Poster
49 posts since Feb 2010
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: