douqian5920 2018-04-03 10:42
浏览 81

PHP - 包含空格的Firebase数据库路径 - Admin SDK

I'm new to PHP. Actually I've just started using it to manage my database for my Android app. So the problem is in case I want to edit an item. I check first if it exists so I can load its info in a new page. Here's the function I used to do it (after Firebase initialization):

function findMovie($database){
    $snapshot = $database->getReference('Movies/'.$_POST['movieType'])->getSnapshot();
    if ($snapshot->hasChild($_POST['movieName'])) {
        header('Location: index.php');
        exit;
    }
    else{
        echo '<div class="alert alert-danger" role = "alert" >
                <strong>Error!</strong> A movie with the given name, <a href="#" class="alert-link">, cannot be found</a>.
            </div >';
        echo "Movie Name: ".$_POST['movieName'];
    }
}

The problem is if the item has a space in its name, an error occurs:

Fatal error: Uncaught JmesPath\SyntaxErrorException: Syntax error at character 4 The Revenant ^ Did not reach the end of the token stream in...

And it works perfectly if it doesn't!

Here's the path in my database:

Enter image description here

I tried with hello, and it works fine... Is there a solution?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
    • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
    • ¥15 cmd cl 0x000007b
    • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
    • ¥500 火焰左右视图、视差(基于双目相机)
    • ¥100 set_link_state
    • ¥15 虚幻5 UE美术毛发渲染
    • ¥15 CVRP 图论 物流运输优化
    • ¥15 Tableau online 嵌入ppt失败
    • ¥100 支付宝网页转账系统不识别账号