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 comsol电力电缆载流量仿真
  • ¥15 webSocket可以接TCP socket接口吗
  • ¥60 mpi并行出错,CFD++计算
  • ¥15 c#:vsto,powerpoint的外接程序中换主题颜色
  • ¥15 状态机/汽车转向灯/Sateflow
  • ¥15 这个有点复杂 有没有人看看
  • ¥15 用python如何确定子孙元素在父元素中的位置
  • ¥15 obj文件滤除异常高程
  • ¥15 用mathematicas或者matlab计算三重积分