PDA

View Full Version : No punctuation!


tony09uk
04-22-2012, 11:56 PM
I have finally completed my first project. Posting news articles. Well kinda completed, i now have to sort a few little and big bugs/things I dont like.

My main problem is that when I try to create or modify a post, if I try to put add punctuation, i get an error (full stop and commas seem to be fine, but certain combos can change every single row e.g.

#'; generates error
/~@ accepted
:[]{} accepted
:'#>/ changes all rows to :

I am now very confused :'(

jmichae3
04-23-2012, 05:01 AM
I have finally completed my first project. Posting news articles. Well kinda completed, i now have to sort a few little and big bugs/things I dont like.

My main problem is that when I try to create or modify a post, if I try to put add punctuation, i get an error (full stop and commas seem to be fine, but certain combos can change every single row e.g.

#'; generates error
/~@ accepted
:[]{} accepted
:'#>/ changes all rows to :

I am now very confused :'(


is it possible that some of these character sequences need to be escaped?

for instance, the RFC that defines the communication protocol may dictate how certain content should be transmitted/encoded/decoded. for instance, certain characters may be escaped with =xx 2-digit hex character codes or %xx or \x00 or \u0000 for unicode maybe is a common one.
got an ascii chart?
http://jesusnjim.com/programming/ascii_chart.html

jmichae3
04-23-2012, 05:03 AM
just out of curiosity, WHY are you automatedly posting news articles? newsgroups are spammed enough, we don't need any more spammers.

tony09uk
04-23-2012, 12:18 PM
jm, im not sure i understand your answer or the question:s

The punctuation i have posted is an example of which symbols are causing me problems incase there is some issue with those specific charaters. I tried to post some lipsum text to my datbase but it threw up an error. so im guessing there is some common problem that i uave come accross that im not aware of.

I can assure you im not trying to spam anything

jmichae3
04-24-2012, 09:16 AM
jm, im not sure i understand your answer or the question:s

The punctuation i have posted is an example of which symbols are causing me problems incase there is some issue with those specific charaters. I tried to post some lipsum text to my datbase but it threw up an error. so im guessing there is some common problem that i uave come accross that im not aware of.

I can assure you im not trying to spam anything
I think I misunderstood you - miscommunication? I thought you were talking about newsgroup posts. maybe you are talking about news as in some feature of a web site like sf.net has news releases for their projects?
I don't know.

anyway, if you are putting these things into a database, you need to know 4 things:

always filter text input into the database using mysql_real_escape_string() - this will fix a LOT of problems!
apply stripslashes() to the output of the database where text is involved and you have used mysql_real_escape_string() to encode it.
always filter integer number input into the database using int(), and do a range check on it! for instance, on AUTO_INCREMENT columns, those start with 1, so check if they are >= 1
always filter real number input into the database using floatval() or doubleval (both do the same thing, they are aliases for same thing)
when reading text from a <textarea></textarea> control, this control inserts \ characters before quotes. so make sure you apply stripslashes() before applying mysql_real_escape_string().

jmichae3
04-24-2012, 09:19 AM
some of those characters you mentioned are reserved keywords in mysql... this is why I was guessing you weren't using mysql_real_escape_string()....

tony09uk
04-24-2012, 09:14 PM
thankyou, that makes sense, I will have a go with them.

Your guess is correct, it is a news thing for my website. It is my first program I have created using no tutorials, only reference sites so ive come across a lot of probelms lol

tony09uk
04-25-2012, 10:42 PM
mysql_real_escape_string() has worked perfectly, but now I have one more issue.

When a user inputs text like this:

This is some text

and this is another line.

It gets displayed like this:

This is some text and this is another line.

How do I keep the spacing the same when its displayed as when it was input?

jmichae3
04-27-2012, 12:44 AM
nl2br() after stripslashes().

jmichae3
04-27-2012, 12:45 AM
sorry - forgot that step, knew I forgot something.

tony09uk
04-27-2012, 11:27 AM
thankyou jm. i knew there was a function to do it but i didnt know it was