Reputation: 65
I am trying to create a new row to a database using insert into in a php script but after hours looking into it i am getting an error of "syntax error, unexpected T_LNUMBER". I know that php screws it when it reach the "37bf7a30-b6cf-4642-89c9-031c1f6c34d0" string. I tried putting quotes and doublequotes there but nothing worked. Do you know any work arround maybe to help me out. Thanks a lot in advance and sorry for my bad english and the messy code.
mysql_query("INSERT INTO `bbdb_item` (`id`, `application_id`, `type`, `name`, `alias`, `created`, `modified`, `modified_by`, `publish_up`, `publish_down`, `priority`, `hits`, `state`, `access`, `created_by`, `created_by_alias`, `searchable`, `elements`, `params`)
VALUES ('$id',
'1',
'item',
'$name',
'$alias',
'$date',
'$date',
'42',
'$date',
'0000-00-00 00:00:00',
'0',
'0',
'1',
'1',
'42',
'',
'1',
' {\n
"37bf7a30-b6cf-4642-89c9-031c1f6c34d0": {\n "0": {\n "value": "http:\\/\\/www.xxxx.com\\/item\\/$id\\/overview.aspx",\n "text": "",\n "target": "0",\n "custom_title": "",\n "rel": ""\n }\n },\n
"d3d4559f-24eb-46b2-a749-068ebd3eceb3": {\n "0": {\n "value": "$id"\n }\n },\n
"0e366b7c-514a-4a37-b651-e6fe8edf78ff": {\n "0": {\n "value": "$country"\n }\n },\n
' {\n
"metadata.title": "",\n
"metadata.description": "",\n
"metadata.keywords": "",\n
"metadata.robots": "",\n
"metadata.author": "",\n
"config.enable_comments": "1",\n
"config.primary_category": "1"\n}')"
)
Upvotes: 2
Views: 1326
Reputation: 11908
The syntax coloring of this site should already be enough to show you what is going on. Once you reach the line that starts with:
"37bf7a30-b6cf-4642-89c9-031c1f6c34d0":
It stops coloring in the same color as the rest of the query. Your PHP string used "
as delimiters, so over there it considers the rest not to be part of the query and strange things start happening as it has no more clue what you are trying to do.
You should escape the quotes, like this:
\"37bf7a30-b6cf-4642-89c9-031c1f6c34d0\": {
And then for every single occurrence of "
throughout your string.
Upvotes: 1
Reputation: 34591
You have to escape all the double-quotes ("
) like this: \"
.
Upvotes: 1