SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Zealot
    Join Date
    May 2007
    Posts
    163
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    stripslashes() and query string problem

    What could be wrong with the following code;
    1.the striplslashes function doesnt remove the slashes b4
    special xters in the output,rather it prints out stripslashes along with the output.
    2.the username is not echoed in the output and thus i cannot use it in other script.

    Code:
    while($row=mysql_fetch_array($result))
    {
    echo "<span class=style18b>$row[title]</span><br>";
    echo "<style=text-align: justify>stripslashes($row[description])</style><br>";
    echo "<b>Other Link(if any): </b>"."<a href=http://$row[url] target=blank>$row[url]</a>"."<br>";
    echo "<b>Price: </b>".$row[price]."<br>";
    echo "To order,click <a href=order.php?username=$row[username]>here</a><p>";
    }

  2. #2
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    As you're in a string context, PHP can't parse it as a function.
    PHP Code:
    while($row mysql_fetch_array($result)){
        echo 
    '    <p class="style18b">' $row['title'] . '</p>
                <p style="text-align: justify">' 
    stripslashes($row['description']) . '</p>
                <p><b>Other Link(if any): </b><a href="http://' 
    $row['url'] . '" target="blank">' $row['url'] . '</a>
                <p><b>Price: </b>' 
    $row['price']. '</p>
                <p>To order,click <a href="order.php?username=' 
    $row['username'] . '">here</a></p>
        '
    ;

    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  3. #3
    SitePoint Zealot
    Join Date
    May 2007
    Posts
    163
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks.Ive replaced the code with the one here
    and its working.But there's a new problem:a forward
    slash(/) is placed after every username and still cant
    use it in another script.
    Thanks.

  4. #4
    SitePoint Zealot
    Join Date
    Oct 2007
    Posts
    148
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    use a regex to strip it out

  5. #5
    SitePoint Zealot
    Join Date
    May 2007
    Posts
    163
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    how?

  6. #6
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    <?php
    while($row mysql_fetch_array($result)){
        echo 
    '<p class="style18b">' $row['title'] . '</p>
        <p style="text-align: justify">' 
    stripslashes($row['description']) . '</p>
        <p><b>Other Link(if any): </b><a href="http://' 
    $row['url'] . '" target="blank">' $row['url'] . '</a>
        <p><b>Price: </b>' 
    $row['price']. '</p>
        <p>To order,click <a href="order.php?username=' 
    rtrim(trim($row['username']),'/') . '">here</a></p>
        '
    ;

    ?>
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  7. #7
    SitePoint Zealot
    Join Date
    May 2007
    Posts
    163
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks a lot.It's working.
    Just wondering how the slash got there in the first place.


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
  •