小编Den*_*nis的帖子

警告:mysqli_query():无法获取mysqli

我有一个问题,我无法从MySQL数据库中检索结果(通过PHP).我在其他地方使用相同的功能,它完美无瑕.但是在这一点上我一直得到"警告:mysqli_query():无法获取mysqli"错误.下面解释问题的细节.我在PHP中使用了一个非常相似的函数(如下所示的getAllCountries),它可以完美地工作:

function getAllCountries()
{
    $result = db_query("SELECT countryid, name FROM country ORDER BY name ASC");

    echo "<select class=addresscountry name=country>";
    while($row = mysqli_fetch_array($result)) {
      echo '<option value="' . $row['countryid'] . '">' . $row['name'] . '</option>';
    }
    echo "</select>";

    mysqli_close(db_connect());
}
Run Code Online (Sandbox Code Playgroud)

所以问题如下:

我有一个包含以下代码的php文件:

<?php
require 'includes/functions.php';

function getUserPicPath()
{
    $userid = $_SESSION['userid'];

    $result = db_query("SELECT picture FROM user WHERE userid='$userid'");

    while($row = mysqli_fetch_array($result)) {
        $picturepath = $row['picture'];
    }

    echo $picturepath;

    mysqli_close(db_connect());
}
Run Code Online (Sandbox Code Playgroud)

我的functions.php文件有以下行(与其他不相关的函数一起):

require 'dbfunctions.php';
Run Code Online (Sandbox Code Playgroud)

我的dbfunctions.php看起来像这样:

<?php
function db_connect()
{
    require ".db_password.php"; …
Run Code Online (Sandbox Code Playgroud)

php mysql mysqli

15
推荐指数
1
解决办法
5万
查看次数

VSCode 中的 ESLint 未修复保存

我在 VSCode 的 Vue(Nuxt) 项目中使用 ESLint。当我保存时,我希望我的 ESLint 自动运行并自动为我修复所有警告。

这是我在 VSCode 中的 settings.json 文件:

{
    "editor.codeActionsOnSave": {
        "source.fixAll.eslint": true
    },
    "vetur.format.defaultFormatter.js": "vscode-typescript",
    "vetur.validation.template": false,
    "vetur.completion.scaffoldSnippetSources": {},
    "vetur.completion.useScaffoldSnippets": false,
    "vetur.format.defaultFormatter.html": "none",
    "workbench.iconTheme": "material-icon-theme",
    "git.autofetch": true,
    "git.defaultCloneDirectory": "",
    "gitlens.views.repositories.files.layout": "list",
    "editor.tabSize": 2,
    "editor.detectIndentation": false,
}
Run Code Online (Sandbox Code Playgroud)

这是我的 .eslintrc.js 文件:

module.exports = {
  root: true,
  env: {
    browser: true,
    node: true,
  },
  extends: [
    "@nuxtjs",
    "plugin:nuxt/recommended",
    "../.eslintrc.js"
  ],
  rules: {
    //Add custom rules for the frontend here.
    //Rules that are common for shared, frontend and …
Run Code Online (Sandbox Code Playgroud)

lint eslint visual-studio-code vscode-settings

15
推荐指数
7
解决办法
2万
查看次数

在Android中模拟广播

我需要知道如何模仿broadcastreceiver.

我有以下代码,但我不知道如何实际看到它何时接收广播.

public class LocationBroadcastReceiver extends BroadcastReceiver 
{
@Override

public void onReceive(Context context, Intent intent) {


    Bundle b = intent.getExtras();
    Location loc = (Location)b.get(android.location.LocationManager.KEY_LOCATION_CHANGED);

    Toast.makeText(context, loc.toString(), Toast.LENGTH_SHORT).show(); 
    Log.d("com.dennis.test","LOCATION:  " + loc.toString());


}
}
Run Code Online (Sandbox Code Playgroud)

在我的清单中,我有以下内容:

<receiver android:name="com.dennis.test.LocationBroadcastReceiver">
    <intent-filter>
        <action android:name="android.location.LocationManager.KEY_LOCATION_CHANGED" />
    </intent-filter>
</receiver>
Run Code Online (Sandbox Code Playgroud)

android emulation broadcastreceiver

6
推荐指数
1
解决办法
4360
查看次数

Codeigniter restclient无法正常工作

我正在尝试为我的解决方案安装CodeIgniter RESTClient和RESTServer库.(philsturgeon-codeigniter-restclientchriskacerguis-codeigniter-restserver).

我设法让其他服务器启动并运行,但我遇到了其他客户端的问题.

这些是我现在所做的步骤:

  1. 复制Rest.php文件(从GitHub下载)并将其放在libraries文件夹中
  2. 下载Curl库并将其放入库中
  3. 修改了Rest.php中的代码以取消注释$this->_ci->load->library('curl');(如果我将鼠标悬停在此文件中的curl库的用法上,则会收到以下消息):

在CI_Controller中找不到字段'curl'

  1. 我创建了一个名为"Restclient"的新控制器来测试我的API.在这个控制器中,我创建了以下方法:

    function rest_client_example($id)
    {
        $this->load->library('rest', array(
            'server' => 'localhost/codeigniter/api/users/'
        ));
    
        $user = $this->rest->get('volunteer', array('id' => $id), 'json');
    
        var_dump($user);
    }
    
    Run Code Online (Sandbox Code Playgroud)

浏览到http:// localhost/codeigniter/api/restclient/rest_client_example/25然后给我

D:\wamp\www\codeigniter\application\controllers\api\Restclient.php:36:null
Run Code Online (Sandbox Code Playgroud)

执行以下代码而不是上面的代码时,我得到了正确的结果:

    $this->load->library('curl');

    $t = $this->curl->simple_get('api/users/volunteer', array('id'=>$id));
    var_dump($t);
Run Code Online (Sandbox Code Playgroud)

所以我知道卷曲是有效的.

我的猜测是我在加载curl库时遇到了什么问题?

php rest curl codeigniter

5
推荐指数
1
解决办法
580
查看次数

[Vue warn]:beforeCreate 挂钩错误:“ReferenceError:文档未定义”

这可能是一个很遥远的事情,但我无法弄清楚出了什么问题。希望有人能给我一些指示。

我在我的 Nuxt 项目中使用 vue 快速编辑插件:https://github.com/A1rPun/vue-quick-edit

有时我会弹出错误:

[Vue warn]:beforeCreate 挂钩错误:“ReferenceError:文档未定义”

这似乎只在我第一次加载页面时发生(未经确认!),之后它再也不会发生(使用 ctrl+F5,以隐身方式加载,在另一个浏览器中尝试,...),它再也不会显示并且图书馆运作完美。

然而,它让我在使用该库时犹豫不决,因为我不确定错误来自何处以及它是否会影响我的最终用户。

这是我为使用内联可编辑字段而创建的组件:

<template>
  <quick-edit
    :aria-label="label"
    @input="updateValue"
  />
</template>

<script>
import QuickEdit from 'vue-quick-edit'

export default {
  components: { QuickEdit },
  props: {
    label: {
      type: String,
      required: true,
    },
  },
  methods: {
    updateValue (event) {
      // do something
    },
  },
}
</script>

<style lang="scss" scoped>

</style>
Run Code Online (Sandbox Code Playgroud)

javascript document vue.js nuxt.js

3
推荐指数
1
解决办法
4000
查看次数

在C#中解析笨拙的JSON格式

使用DSML在我的大学开发的场景建模场景.现在可以将其导出为JSON格式,示例如下所示:

{
    "_entries": [
        "g0"
    ],
    "_flow": {
        "g3": {
            "_expr": [
                {
                    "word_": "player",
                    "next_": [
                        {
                            "word_": "rebukes",
                            "next_": [
                                {
                                    "word_": "jack"
                                }
                            ]
                        }
                    ]
                }
            ]
        },
        "g4": {
            "_expr": [
                {
                    "word_": "player",
                    "next_": [
                        {
                            "word_": "supports",
                            "next_": [
                                {
                                    "word_": "jack"
                                }
                            ]
                        }
                    ]
                }
            ]
        },
        "g2": {
            "_type": "cho",
            "_paths": [
                "g3",
                "g4"
            ]
        },
        "g1": {
            "_next": "g2",
            "_expr": [
                {
                    "word_": "player",
                    "next_": …
Run Code Online (Sandbox Code Playgroud)

c# json

2
推荐指数
1
解决办法
81
查看次数