SitePoint Sponsor

User Tag List

Results 1 to 21 of 21
  1. #1
    SitePoint Wizard
    Join Date
    Jul 2001
    Location
    The Netherlands
    Posts
    2,617
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Slight problem with slashes

    As the topic says, I have a slight problem with slashes. I have inserted a piece of text, typed in Word, into a table in MySQL. I want the text to appear in a .php-file. This all works quite well. The HTML-tags, I included in the site do their job, except for the links.

    When I have a piece of code like the one below, I seem to get no effect from the stripslashes function:
    Code:
    <a href=\"contact.php\">Contact</a>
    There is nothing wrong with the PHP coding, the text just appears normally. I declared the variable in the following way:

    PHP Code:

    $about 
    $result[text];
    $about stripslashes($about); 
    Can someone tell me what terrible mistake I am making?

  2. #2
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You do not need to escape "s in HTML if it is being stored in the database, only if it is in the PHP script

    Sean
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature

  3. #3
    SitePoint Wizard
    Join Date
    Jul 2001
    Location
    The Netherlands
    Posts
    2,617
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, without all the addslashes() and stripslashes() I have the same effect. The link points to the page |contact.php| instead of to contact.php.

    What would be the cause of this then?

  4. #4
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Could you show us the code and the text you are grabbing from the db?

    Sean
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature

  5. #5
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Answer to problem with slashes (Rafe's question)

    The problem is simple:

    You are using instead of " (shift and 2 yeah)

    Moderators: Take a look at that thread. The code he posted completely screwed vB and you can not reply to the thread.

    Sean
    Last edited by seanf; Jul 28, 2001 at 06:32.
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature

  6. #6
    SitePoint Wizard
    Join Date
    Jul 2001
    Location
    The Netherlands
    Posts
    2,617
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I did seem to be able to get to the reply-screen after posting that gigantic piece of code, but I deleted it anyway, to prevent any problems.

  7. #7
    SitePoint Wizard
    Join Date
    Jul 2001
    Location
    The Netherlands
    Posts
    2,617
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't quite get that, what did I do wrong? In stead of " I should use what?

    I mean <tag attribute="property"> seems like normal HTML-syntax to me ...

  8. #8
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Look closer:

    and "

    One is angled the other is straight. This is the problem, I am 100% positive, without a doubt. I tried it.

    Sean
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature

  9. #9
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could get to it, but the buttons were not there so you could not reply. Stupid vB

    Sean
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature

  10. #10
    SitePoint Wizard
    Join Date
    Jul 2001
    Location
    The Netherlands
    Posts
    2,617
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Okay, I get it now. Thanks, I think I have the problem pinned down now. My guess is that is has something to do with the fact that I used Word to type the piece of text.

    Just checked it. In my MySQL-DB the quotation marks are not in italic, so that is not the problem.

  11. #11
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It is the porblem!

    I copied all of the code you posted and had the same problems with the links (|contact.php|).

    When I changed the quotation marks (in the text stored in the db) everything was fine

    Sean
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature

  12. #12
    SitePoint Wizard
    Join Date
    Jul 2001
    Location
    The Netherlands
    Posts
    2,617
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So, I should change the quotation marks, which are in my DB not in italic, into new ones, and that should solve it?

    Okay, I may be a little slow of understanding, but this I will give it a go. I still don't get how that could have happened and how this solution should change it, but we will see.

    Thanks for putting up with me though .

  13. #13
    SitePoint Wizard
    Join Date
    Jul 2001
    Location
    The Netherlands
    Posts
    2,617
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Magical indeed...

    I seem to have no grasp on reality anymore. I replaced the quotation marks with new ones, and it looked exactly the same in the database, but when I looked to the ouput, the | | were gone ....

    Okay, I am really going insane now!

  14. #14
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Edit:

    oops!
    Last edited by seanf; Jul 28, 2001 at 08:00.
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature

  15. #15
    SitePoint Wizard
    Join Date
    Jul 2001
    Location
    The Netherlands
    Posts
    2,617
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think you got my post wrong. The problem had been solved. I just copied the Word-doc to Notepad, and then into my MySQL-table, and that seemed to do the tric.

    I was just amazed, because I used phpMyAdmin, and I didn't see any italics, or my eyes must be fooling me. Anyway, I won't start thinking about a possible cause for that, I am just glad it is all fixed.

    On to the next page, and thus to the next bug !

  16. #16
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah, sorry Rafe I was just about to edit my post but I had to drive my Dad into town!

    My suggestion would be to use notepad in the future

    Sean
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature

  17. #17
    SitePoint Wizard
    Join Date
    Jul 2001
    Location
    The Netherlands
    Posts
    2,617
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I will gladly take that suggestion. I will be using Word for the original typing of the text, and then spell check it. As you can see beneath my avatar, I live in Holland, and my English is quite well, but not superb and I like the idea of spell-error-free articles on my new site.
    After that I will copy it to Notepad and from here place it in my database.
    Thanks for todays help though, and count on me having some other problem somewhere tomorrow !

  18. #18
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't use Word very often. However I'm pretty sure that there is an option that you can set to use or not use "smart quotes". Smart quotes are the qoutes that curl around your qouted text like tiny 66 and 99 if you know what I mean. You just want plain old ASCII text. You could probably achieve this by saving the doc as a ASCII txt doc or by changing the "smart quotes" setting.

  19. #19
    SitePoint Wizard
    Join Date
    Jul 2001
    Location
    The Netherlands
    Posts
    2,617
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The Word-Notepad-database way may be a long way, but I can live with that. It keeps me free from such things like smart quotes, so that my pages will look clean and are clear-coded.

    Thanks for the tip though .

  20. #20
    Your Lord and Master, Foamy gold trophy Hierophant's Avatar
    Join Date
    Aug 1999
    Location
    Lancaster, Ca. USA
    Posts
    12,305
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    You could get a tool like Textpad (www.textpad.com) that has built in Spellchecking, then you wouldn't need to go from Word-Notepad-Database...

    Or you could simply choose Save As... from the file menu in Word and save your articles as Text (.txt) which strips out all the formatting including smart quotes.
    Wayne Luke
    ------------


  21. #21
    SitePoint Wizard
    Join Date
    Jul 2001
    Location
    The Netherlands
    Posts
    2,617
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by W. Luke
    Or you could simply choose Save As... from the file menu in Word and save your articles as Text (.txt) which strips out all the formatting including smart quotes.
    That is what I like about SitePoint. I am a guy that tends to forget very logical solutions to a problem and is always trying to fix things the difficult way. It is a great teacher though, but I need a community with people like here on SitePoint to point me towards the obvious direction.

    Thanks for that pointer !


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •