single and double quotes problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pradeepjain
    Contributor
    • Jul 2007
    • 563

    single and double quotes problem

    i have values like
    alias = Indus International School"In omnia paratus", meaning "Prepared for all challenges"
    model = "In omnia paratus", meaning "Prepared for all challenges"

    Code:
    $myresult .= "<a href=\"Schools/".$_row['alias']."\"><img src=\"/school/schoolpicdisplay.php?p1=".$brand."&p2=".$row['model']." \" width=\"50\" height=\"80\"></img></a>";
    when i try to print the alias and model values are not coming . what the work arounf for it . I have used mysql_real_esca pe_string while inserting to DB. what must be done while printing or after taking out of db.
    Last edited by Dormilich; Feb 24 '10, 06:47 PM. Reason: Please use [code] tags when posting code
  • dlite922
    Recognized Expert Top Contributor
    • Dec 2007
    • 1586

    #2
    use single quotes for html attributes?

    Code:
    $result = "<a href='{$row['alias']}'><img src='/school/schoolpicdisplay.php?p1={$brand}&pd={$row['model']}' width='50' height='80' /></img></a>"
    Dan

    Comment

    • pradeepjain
      Contributor
      • Jul 2007
      • 563

      #3
      That worked
      whats the actual problem in the way i used ?

      whts the difference b/w if i use {$model} or ".$model." will it make any difference ?

      Now its giving problems for the single quotes thing like

      model = Sri Kumaran Children's Home

      its not printing completely its printing till Sri Kumaran Children the url looks like

      Code:
      $myresult .= "<a href='Schools/{$alias}'><img src='/school/schoolpicdisplay.php?p1={$brand}&p2={$model}' width=\"50\" height=\"80\"></img></a>";
      Last edited by Dormilich; Feb 24 '10, 06:48 PM. Reason: Please use [code] tags when posting code

      Comment

      • pradeepjain
        Contributor
        • Jul 2007
        • 563

        #4
        how to handle the single quote problem ?

        Comment

        • dlite922
          Recognized Expert Top Contributor
          • Dec 2007
          • 1586

          #5
          use url_encode().



          Dan

          Comment

          • pradeepjain
            Contributor
            • Jul 2007
            • 563

            #6
            yeah i used rawurlencode . i learnt 2 main thing by this question .

            1. to encode the variable when passing through the urls

            2. to use mysql_real_esca pe_string when using the variable in a mysql statement .

            any things else important i have left out while handling quotes ?

            Comment

            • pradeepjain
              Contributor
              • Jul 2007
              • 563

              #7
              i solved tht quotes problem with the rawurlencode . but i am facing another problem. like
              the alias has value like $alias = "Sony DSC-TX1/H"
              when i am making it an url like

              Code:
              <a href="<?php echo ucfirst($value).'/'.rawurlencode($row1['alias']); ?>"><?php echo $row1['property1']; echo " ";echo $row1['property2'] ?></a>
              its leading to a page not found like
              The requested URL /Cameras/SonyDSC-TX1/H was not found on this server.
              the / is making a prob .will the rawurlencode take care of slash?

              Comment

              Working...