Web Analytics Made Easy -
StatCounter Does double + always reads as string concatention in Php? - CodingForum


No announcement yet.

Does double + always reads as string concatention in Php?

  • Filter
  • Time
  • Show
Clear All
new posts

  • Does double + always reads as string concatention in Php?

    I've encountered a problem. Im making a program for e-lib catalogue.
    My programs goes like querying the title, author of a book.

    ex. File structures : an object-oriented approach with C++

    It actually displays the data that I want to display but, When I'm going to click the said
    title " File structures : an object-oriented approach with C++" to view the details of this book. the php would read the phrase C++ into C_ _ meaning it was being concatenated becuse of the double +.

    My problem how could i solve this.

    heres my program.


    while statement
    echo '
    <td bgcolor="'.$kol.'">'.$row[num].'</td>
    <td bgcolor="'.$kol.'">'.$name.'</td>
    <td bgcolor="'.$kol.'">';
    echo '<div id="menux">
    <A href="'; echo $_SERVER["PHP_SELF"]; echo '?click='.$title.'&author='.$row[lname].'">'.$title.'</a></div></td>';
    echo '<td bgcolor="'.$kol.'">'.$row[year].'</td></tr>';



    the title must be the same , but php assumes that it was concatenation symbol

    pls any idea.

  • #2
    Ur problem is not actually with php...it has to do with the url encoding if im right. try encoding the title variable before u put it into the a reference tag. as in somthing like this:
    PHP Code:
    $title urlencode($title);
    //...other things
    echo '<div id="menux"><A href="';
    '<td bgcolor="'.$kol.'">'.$row[year].'</td></tr>';
    then from where u will be getting the result, u can as well decode it back -
    PHP Code:
    $title urldecode($_GET['click']); 


    • #3
      the ++ operator doesn't concatinate anyway...

      why do you need to pass the title and author? normally, you'd past the primary key value for that book and do a new lookup (if necessary) on the targetted page to get the title and author. you are setting yourself open to all sort of security-issues by passing strings throught the url...

      look at how for instance this forum works: it wountpass the thread or posttitle in the querystring, it will just pass the PK value for the respective table...
      Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html