mysqli的工作直接而不是通过时,JS-AJAX运行时 [英] mysqli works when run directly but not when via js-ajax

查看:114
本文介绍了mysqli的工作直接而不是通过时,JS-AJAX运行时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数据库的信息放在一个PHP脚本。 当我手动服务器的所有作品上运行脚本预期。 但是,当我运行,它通过使用Ajax的PHP脚本的javascript非常脚本未能在以下行:

I have a php script that places information in a db. When i run the script manually on the server all works as expected. But when I run that very script via javascript using ajax the php script fails at the following line:

$connection=new mysqli($servername,$username,$password,$dbname);

和我得到的错误 PHP的致命错误:类'mysqli的在/ var没有找到/ www / html等/..

And the error i get is PHP Fatal error: Class 'mysqli' not found in /var/www/html/..

这没有任何意义,因为我只是跑了很脚本的服务器没有问题,直接上。

Which doesn't make any sense for I just ran that very script directly on the server with no problem.

我在/var/log/apache2/error.log发现这个错误。

I'm finding this error in /var/log/apache2/error.log.

下面是我的ajax调用的样子:

Here's how my ajax call looks:

$.ajax({
    url:'db/insert.php',
    complete: function(response){
        //$('#output').html(response.responseText);
        alert('complete: '+response.responseText);
        },
    error: function(){
        //$('#output').html('Bummer: there was an error!');
        alert('error');
        },
    async:"false",
    type:"POST",
    data:{visit_report:'1'}
    });

为什么脚本以这种方式失败?

Why is the script failing in this way?

这个问题是继续在这里: <一href="http://stackoverflow.com/questions/31535173/enable-mysqli-in-my-in-webserver-copy-of-php">Enable的mysqli在PHP 我在,Web服务器副本

This question is continued here: Enable mysqli in my in-webserver copy of php

推荐答案

查找您的php.ini 文件,要小心可能有2人。你可能想要一个在你的apache / bin文件夹。

Find you php.ini file, be careful there may be 2 of them. You probably want the one in your apache/bin folder.

查找

extension=php_mysqli.so

请确保它不会在它的前面有一个注释字符。

Make sure it does not have an # comment character at the front of it.

如果你不知道它生活的地方尝试 whereis的php.ini文件

If you are not sure where it lives try a whereis php.ini

这篇关于mysqli的工作直接而不是通过时,JS-AJAX运行时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆