weixin_33726318 2015-03-29 21:45 采纳率: 0%
浏览 7

ajax无法与mysqli连接?

I am trying to connect with myqli trought a ajax call. cause i am testing the database input of the user.

The script is crashing at: $testBase = new mysqli("sfd", "sdf", "sdg", "sdf");

And in the console stands: Uncaught SyntaxError: Unexpected token <

Yes u searched this question but by most people you'll get that error when you do a query and mine is doing that already when i try to create a mysqli connection.

Ajax script:

if (error == false){
var name = $('#name').val(),
    url = $('#url').val(),
    datahost = $('#datahost').val(),
    datausername = $('#datausername').val(),
    datapassword = $('#datapassword').val(),
    dataname = $('#dataname').val(),
    license = $('#license').val(),
    data = 'name='+ name +'&url='+ url +'&datahost='+ datahost +'&datausername='+ datausername +'&datapassword='+ datapassword +'&dataname='+ dataname +'&license='+ license;

$( "#trans" ).fadeIn( 500, function() {
    $.ajax({
        type: "POST",
        url: "handlers/install.php",
        data: data,
        success: function(e){ // this happen after we get result
            react(e);
        }
    });
});

}

please help me

The response of handelers/install.php is:

"<br />
<b>Warning</b>:  mysqli::mysqli(): (HY000/1130): Host 'server2.ughost.nl' is not allowed to connect to this MySQL server in <b>/home/universa/public_html/klant/handlers/install.php</b> on line <b>59</b><br />
<br />
<b>Warning</b>:  mysqli::close(): Couldn't fetch mysqli in <b>/home/universa/public_html/klant/handlers/install.php</b> on line <b>75</b><br />
{\"ban\":0,\"error\":0,\"license\":0,\"url\":0,\"name\":0,\"sql\":0,\"message\":\"localhost + asd + asdas+dasf\"}"
  • 写回答

1条回答 默认 最新

  • python小菜 2015-03-29 23:46
    关注

    Ok the problem was that the install.php always give a warning when the login is incorrect. But i needed to check it because this is a users input so how did i fix it?

    error_reporting(0);
                            $testBase = new mysqli($datahost, $datausername, $datapassword, $dataname);
                            error_reporting(1);
                            if ($testBase->connect_errno) {
                                $response['sql'] = 1;
                                $testBase->close();
                            } else {
                                //can connect with database
                                $testBase->close();
    
                            }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 在若依框架下实现人脸识别
  • ¥15 网络科学导论,网络控制
  • ¥100 安卓tv程序连接SQLSERVER2008问题
  • ¥15 利用Sentinel-2和Landsat8做一个水库的长时序NDVI的对比,为什么Snetinel-2计算的结果最小值特别小,而Lansat8就很平均
  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同