logo-dw

Go Back   Dreamweaver Club Forums > Hand Coders Forum > PHP
Register FAQ Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
Old 04-22-2012, 11:56 PM   #1
tony09uk
 
Join Date: Oct 2010
Posts: 340
Default No punctuation!

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 :'(
tony09uk is offline   Reply With Quote
Old 04-23-2012, 05:01 AM   #2
jmichae3
 
Join Date: Dec 2010
Posts: 366
Default

Quote:
Originally Posted by tony09uk View Post
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 is offline   Reply With Quote
Old 04-23-2012, 05:03 AM   #3
jmichae3
 
Join Date: Dec 2010
Posts: 366
Default

just out of curiosity, WHY are you automatedly posting news articles? newsgroups are spammed enough, we don't need any more spammers.
jmichae3 is offline   Reply With Quote
Old 04-23-2012, 12:18 PM   #4
tony09uk
 
Join Date: Oct 2010
Posts: 340
Default

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
tony09uk is offline   Reply With Quote
Old 04-24-2012, 09:16 AM   #5
jmichae3
 
Join Date: Dec 2010
Posts: 366
Default

Quote:
Originally Posted by tony09uk View Post
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().
__________________
------------
Jim Michaels
HTML Code:
improperly<strong>nested<em>elements</strong>cause</em>
browser confusion (I believe the term is 'tag soup')!
jmichae3 is offline   Reply With Quote
Old 04-24-2012, 09:19 AM   #6
jmichae3
 
Join Date: Dec 2010
Posts: 366
Default

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()....
__________________
------------
Jim Michaels
HTML Code:
improperly<strong>nested<em>elements</strong>cause</em>
browser confusion (I believe the term is 'tag soup')!
jmichae3 is offline   Reply With Quote
Old 04-24-2012, 09:14 PM   #7
tony09uk
 
Join Date: Oct 2010
Posts: 340
Default

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 is offline   Reply With Quote
Old 04-25-2012, 10:42 PM   #8
tony09uk
 
Join Date: Oct 2010
Posts: 340
Default

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?
tony09uk is offline   Reply With Quote
Old 04-27-2012, 12:44 AM   #9
jmichae3
 
Join Date: Dec 2010
Posts: 366
Default

nl2br() after stripslashes().
__________________
------------
Jim Michaels
HTML Code:
improperly<strong>nested<em>elements</strong>cause</em>
browser confusion (I believe the term is 'tag soup')!
jmichae3 is offline   Reply With Quote
Old 04-27-2012, 12:45 AM   #10
jmichae3
 
Join Date: Dec 2010
Posts: 366
Default

sorry - forgot that step, knew I forgot something.
__________________
------------
Jim Michaels
HTML Code:
improperly<strong>nested<em>elements</strong>cause</em>
browser confusion (I believe the term is 'tag soup')!
jmichae3 is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 06:04 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Copyright 2006 DreamweaverClub.com