Unterminated String constant error

B

Bhushan Kakulte

Hi,

I have content from textarea which contains newline character also. I
am storing this data in database.
<textarea id="text1">unknown
data</textarea>

I extract the data (textarea value) we stored in database. When I
tried to use this content in table it gives string unterminated
constant error.
consider val1=text1.value
<table>
<tr>
<td title=val1> </td>
</tr>
</table>

Please tell me how to handle newline character from textarea.

Thanks,
Bhushan
 
E

Erwin Moller

Hi,

I have content from textarea which contains newline character also. I
am storing this data in database.
<textarea id="text1">unknown
data</textarea>

First check:
Did that work alright?
Is the data actually stored in the database?

I extract the data (textarea value) we stored in database. When I
tried to use this content in table it gives string unterminated
constant error.
consider val1=text1.value

What has "val1=text1.value" to do with the data you took out of the
database?
I would expect you have some data stored in some serverside variable.
You above example (val1=text1.value) is Javascript (sort of).


<table>
<tr>
<td title=val1> </td>

That makes no sense at all.
Please explain what you are trying to do.

If you want the title of that <td> to hold information from the database
you should do something like this:
[PHP example]

<td title="<?php echo $myTitle; ?>">...</td>

Mind the "".
Also make sure $myTitle is appropriately escaped.
When the raw data for title contains " you get into trouble when you
don't escape.

</tr>
</table>

Please tell me how to handle newline character from textarea.

What do you want to do with the data from the textarea?
You question is impossible to answer without such context.

It is like you ask me: "What must I do with this 10 dollar note?".
Give some context, and people can help you better.

Thanks,
Bhushan

Regards,
Erwin Moller
 
T

Thomas 'PointedEars' Lahn

Erwin said:
If you want the title of that <td> to hold information from the database
you should do something like this:
[PHP example]

<td title="<?php echo $myTitle; ?>">...</td>

Mind the "".
Also make sure $myTitle is appropriately escaped.

Like

When the raw data for title contains "

or `<' and `&'.
you get into trouble when you don't escape.

ACK.


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top