Problems with PHP and " "

Discussion in 'Programming' started by efrainuzco, Feb 8, 2007.

  1. #1
    Hi there!

    I'm working on PHP, and I have the following problem:

    I have a form page, and then when I type something between " ", and click the preview button I can see everything alright, but when I click the back button the text between " " disapears including the " ".

    What could it be?

    Thanks in advance.
     
    efrainuzco, Feb 8, 2007 IP
  2. YIAM

    YIAM Notable Member

    Messages:
    2,480
    Likes Received:
    240
    Best Answers:
    0
    Trophy Points:
    280
    #2
    try adding "\"

    example:

    echo "My name is \"abcd\" ";
     
    YIAM, Feb 8, 2007 IP
  3. efrainuzco

    efrainuzco Guest

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    thank you very much, it really works, but my problem is that Im not using fixed text but fields which can have different content and I will never know where exactly the quotation marks are.

    e.g I may type either Hi, my name is "robot" Or I have a "real" problem.

    Thanks in advance.
     
    efrainuzco, Feb 8, 2007 IP
  4. papa_face

    papa_face Notable Member

    Messages:
    2,237
    Likes Received:
    67
    Best Answers:
    1
    Trophy Points:
    285
    #4
    A simpler way is to use ' instead of " and use them together.
    e.g
    echo 'My name is "abcd" ';

    If you want to change the name dynamically, im presuming you are submitting the text feild..
    Simply do

    
    <?php
    
    $name = $_POST['name'];
    
    echo 'Your name is "' . $name . '"';
    
    ?>
    
    
    PHP:
     
    papa_face, Feb 8, 2007 IP
  5. efrainuzco

    efrainuzco Guest

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thank you very much papa face!
     
    efrainuzco, Feb 8, 2007 IP