drxp993551 2011-09-09 00:26
浏览 229

存储在MySQL中的Url返回每个正斜杠的额外反斜杠(a / b.png => a \ /b.png)

I have a MySql database with a URL field that has normal URLs with forward slashes. When I get the URL data with PHP web service it shows up with a backward slash for each forward slash:

http://example.com/iphone/images/test.png

shows as

http:\/\/example.com\/iphone\/images\/test.png

What could be the problem?


Here is the function that gets my data.

function getdata() {

    // Check for required parameters
    if (isset($_POST["genre"])) {

        // Put parameters into local variables
        $genre = $_POST["genre"];

        // Final result array
        $final_result = array();

        // Look up in database
        $user_id = 0;
        $stmt = $this->db->prepare('SELECT ID, BAND, VENUE, GENRE, DATE, THUMBNAIL_URL, DESCRIPTION FROM shows WHERE GENRE=?');
        $stmt->bind_param("s", $genre);
        $stmt->execute();
        $stmt->bind_result($id, $band_result, $venue_result, $genre, $date, $thumbnail_url, $description);
        while ($stmt->fetch()) {


            $thumbnail_url = stripslashes($thumbnail_url);

            $result = array(
            "id" => $id, "band" => $band_result, "venue" => $venue_result, "genre" => $genre, "date" => $date, "thumbnail_url" => $thumbnail_url, "description" => $description,
            );
            $final_result[] = $result;
            continue;
        }
        $stmt->close();





        sendResponse(200, json_encode($final_result));
        return true;
    }
    sendResponse(400, 'Invalid request');
    return false;
}
  • 写回答

2条回答 默认 最新

  • duanqiu9104 2011-09-09 00:34
    关注

    If it's showing up in the database with slashes; that's fine.

    If you want to remove them in your PHP after getting them out of the database, run it through stripslashes();

    $url = stripslashes($url);
    

    If you want to strip the slashes before it goes into the database... same as above, but think twice before you do :)

    评论

报告相同问题?

悬赏问题

  • ¥15 Mac系统vs code使用phpstudy如何配置debug来调试php
  • ¥15 目前主流的音乐软件,像网易云音乐,QQ音乐他们的前端和后台部分是用的什么技术实现的?求解!
  • ¥60 pb数据库修改与连接
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)