首页 \ 问答 \ phonegap / msql(i)无法建立与数据库的连接(phonegap/msql(i) can't establish connection to database)

phonegap / msql(i)无法建立与数据库的连接(phonegap/msql(i) can't establish connection to database)

我目前正在为iOS开发一个网络应用程序,但该应用程序无法正确连接。

当我尝试登录时,我得到以下iOS弹出窗口:index.html错误。

当PHP文件在线时,

这里有一些我的代码:

connection.php

<?php //Make connection with database
// Verbinden met MySQL Database
$host = "localhost"; // Welke server : localhost 
$username = "*******"; // Gebruikersnaam
$password = "****"; // Wachtwoord
$dbnaam = "*****"; // Naam van de database
$db_error1 = "<p>FOUT: verbinden met databaseserver is mislukt</p>"; // Foutmelding 1
$db_error2 = "<p>FOUT: selecteren van database is mislukt</p>"; // Foutmelding 2
$db_error3 = "<p>FOUT: sluiten van database is mislukt</p>"; // Foutmelding 3

// Verbinden met Databaseserver
$con=mysqli_connect($host, $username, $password, $dbnaam);// or die($db_error1);
// verbinden met de database
//mysql_select_db($dbnaam, $db) or die($db_error2);
if (mysqli_connect_errno($con))
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }
?>

demo.js

// define the URL of the server component
//var url ="http://www.jorisgraaumans.nl/dutchmobile/";
//var url = "http://localhost:8888/Mobile/Festival/";
var url = "http://www.rikvandoorn.com/mobile/";

// afvangen van het standaard submit event
// zie ook: http://api.jquery.com/submit/

$('#login').on('pageinit', function(event) {
    $('#loginForm').submit(function() {
        $.ajax({
            type: "POST",
            url: "processLogin.php",
            cache: "false",
            dataType: "json",
            data: {
                email : $('#email').val(),
                wachtwoord : $('#wachtwoord').val(),
            },
            success: function(phpData){ 
                $("#return").data("login", phpData.login);
                console.log("login is: "+ phpData.login);
                if(phpData['error'] == true){
                    $.mobile.changePage("#return", {
                        transition : "fade"
                    })
                } else {
                    $.mobile.changePage("#home", {
                        transition : "fade"
                    })
                }
            },  
            error: function(){
                    alert('Error');
            }                   
        }); 
        return false; // return false to prevent the default submit of the form to the server.
    });
    // end: pageinit loginForm  
});
$('#return').on('pageshow', function(event) {
    $("#error_message_log").empty();
    $("#error_message_log").prepend('<p>' +  $(this).data('login') + '</p>');
});

processLogin.php

<?php //process login form 

include 'http://www.rikvandoorn.nl/mobile/connect.php'; //connection to database
if(empty($_POST['email']) || empty($_POST['wachtwoord'])){
    $return['error'] = true;    //return error
    $return['login'] = 'Niet alle velden zijn ingevuld';
} else {
    $email = $_POST['email'];
    $wachtwoord = $_POST['wachtwoord'];

    //Check if user exists
    $sql = "SELECT * FROM gebruiker WHERE email = '$email'";
    $result = mysql_query($sql) or die(mysql_error());
    $num_rows = mysql_num_rows($result);    

    if($num_rows == 0){
        $return['error'] = true;
        $return['login'] = 'Gebruiker bestaat niet';
    } else {
        //Check if password is correct for user
        $sql_2 = "SELECT * FROM gebruiker WHERE email = '$email'  && wachtwoord = '$wachtwoord'";
        $query_2 = mysql_query($sql_2);
        $num_rows_2 = mysql_num_rows($query_2);
        if($num_rows_2 == 0){
            $return['error'] = true;
            $return['login'] = 'Wachtwoord onjuist';
        } else {
            $return['error'] = false;
            $return['login']['email'] = $email;
            $return['login']['wachtwoord'] = $wachtwoord;
        }
    }
}
echo json_encode($return);

i'm currently developing an web app for iOS but the app can't get the connection right.

when i'm trying to log in, i get the following iOS popup: index.html Error.

while the PHP files are online,

here some of my code:

connection.php

<?php //Make connection with database
// Verbinden met MySQL Database
$host = "localhost"; // Welke server : localhost 
$username = "*******"; // Gebruikersnaam
$password = "****"; // Wachtwoord
$dbnaam = "*****"; // Naam van de database
$db_error1 = "<p>FOUT: verbinden met databaseserver is mislukt</p>"; // Foutmelding 1
$db_error2 = "<p>FOUT: selecteren van database is mislukt</p>"; // Foutmelding 2
$db_error3 = "<p>FOUT: sluiten van database is mislukt</p>"; // Foutmelding 3

// Verbinden met Databaseserver
$con=mysqli_connect($host, $username, $password, $dbnaam);// or die($db_error1);
// verbinden met de database
//mysql_select_db($dbnaam, $db) or die($db_error2);
if (mysqli_connect_errno($con))
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }
?>

demo.js

// define the URL of the server component
//var url ="http://www.jorisgraaumans.nl/dutchmobile/";
//var url = "http://localhost:8888/Mobile/Festival/";
var url = "http://www.rikvandoorn.com/mobile/";

// afvangen van het standaard submit event
// zie ook: http://api.jquery.com/submit/

$('#login').on('pageinit', function(event) {
    $('#loginForm').submit(function() {
        $.ajax({
            type: "POST",
            url: "processLogin.php",
            cache: "false",
            dataType: "json",
            data: {
                email : $('#email').val(),
                wachtwoord : $('#wachtwoord').val(),
            },
            success: function(phpData){ 
                $("#return").data("login", phpData.login);
                console.log("login is: "+ phpData.login);
                if(phpData['error'] == true){
                    $.mobile.changePage("#return", {
                        transition : "fade"
                    })
                } else {
                    $.mobile.changePage("#home", {
                        transition : "fade"
                    })
                }
            },  
            error: function(){
                    alert('Error');
            }                   
        }); 
        return false; // return false to prevent the default submit of the form to the server.
    });
    // end: pageinit loginForm  
});
$('#return').on('pageshow', function(event) {
    $("#error_message_log").empty();
    $("#error_message_log").prepend('<p>' +  $(this).data('login') + '</p>');
});

processLogin.php

<?php //process login form 

include 'http://www.rikvandoorn.nl/mobile/connect.php'; //connection to database
if(empty($_POST['email']) || empty($_POST['wachtwoord'])){
    $return['error'] = true;    //return error
    $return['login'] = 'Niet alle velden zijn ingevuld';
} else {
    $email = $_POST['email'];
    $wachtwoord = $_POST['wachtwoord'];

    //Check if user exists
    $sql = "SELECT * FROM gebruiker WHERE email = '$email'";
    $result = mysql_query($sql) or die(mysql_error());
    $num_rows = mysql_num_rows($result);    

    if($num_rows == 0){
        $return['error'] = true;
        $return['login'] = 'Gebruiker bestaat niet';
    } else {
        //Check if password is correct for user
        $sql_2 = "SELECT * FROM gebruiker WHERE email = '$email'  && wachtwoord = '$wachtwoord'";
        $query_2 = mysql_query($sql_2);
        $num_rows_2 = mysql_num_rows($query_2);
        if($num_rows_2 == 0){
            $return['error'] = true;
            $return['login'] = 'Wachtwoord onjuist';
        } else {
            $return['error'] = false;
            $return['login']['email'] = $email;
            $return['login']['wachtwoord'] = $wachtwoord;
        }
    }
}
echo json_encode($return);

原文:https://stackoverflow.com/questions/17430177
更新时间:2023-09-24 07:09

最满意答案

我发现了问题。 这是由于延伸“我在哪里”。 我的扩展程序可用于Visual Studio 2010.这不适用于VS 2012.我做了一个hack以便它可以安装在VS 2012上。这导致了这个问题。 我禁用了这个扩展,现在一切正常。


I found the problem. It was due to a extension "Where Am I". Where Am I extension is available for Visual Studio 2010. This is not available for VS 2012. I did a hack so that it can be installed on VS 2012. This caused this problem. I disabled that extension, and now everything working fine.

相关问答

更多
  • 看来罪魁祸首是执行IL编织的第三方库(Fody.PropertyChanged)。 如果我没有这个库创建一个新的WPF项目,我可以在Watch窗口中使用Math.Sin() 。 一旦我安装PropertyChanged ,我开始得到“在这种情况下不可用”的错误。 感谢@BACON带领我找到正确的道路。 以下是我在PropertyChanged网站上发布的问题的链接: http://code.google.com/p/propertychanged/issues/detail?id=6&thanks=6&ts ...
  • 你在这里看到的行为是一个错误。 在这种情况下,C#调试器不应显示静态成员。 我向代码库的当前所有者证实了这一点,他将为Visual Studio的下一个版本提交一个错误。 发生这种情况的具体方案是 Just My Code已启用 该类型定义为确定为非用户程序集的内容 引用和对象实例的类型不同(将hash2切换为SHA1Cnf ,问题消失) 请注意,可能会出现其他情况。 这是我在调试/实验中能够缩小范围的行为。 The behavior you are seeing here is a bug. The C# ...
  • 由于你的枚举值,这似乎不可能:如果myFlags值为3那么这可能是e_SecondFlag | e_ThirdFlag e_SecondFlag | e_ThirdFlag或e_FourthFlag ,都将返回3 。 由于权力为2,因此您不会遇到此问题,因为每个值只能以一种方式组合。 你要么必须切换到2的权力,要么对你拥有的东西保持满意。 void Main() { var flags = Flags.FourthFlag; Console.WriteLine ((int) flags); ...
  • 我不得不将C:\ Users \ username \ Documents \ Visual Studio 2008 \ Visualizers中的所有文件复制到C:\ Program Files(x86)\ Microsoft Visual Studio 8 \ Common7 \ Packages \ Debugger \ Visualizers。 特别是它缺少autoexp.dll和autoexpce.dll。 I had to copy all the files in C:\Users\usern ...
  • 要清除即时窗口,可以使用>cls ,这是>Edit.ClearAll的预定义命令别名 。 MSDN文章列出了所有预定义的别名,您也可以定义自己的别名。 (对于VS 2010和更早版本, 自定义别名将在另一篇文章中进行描述。)扫描过程中,有一些它们,其中一些甚至可能根植于MS-DOS DEBUG.EXE(具体>d , >g , >p , >q ,并且不要想到)。 另外值得一提的是,只需按两下键即可:上下文菜单>全部清除调用相同的命令,并可以使用键盘导航。 在即时窗口中,您可以按context-menu L 如 ...
  • 您应该在Visual Studio命令提示符中运行它,而不是在Visual Studio的命令窗口中运行它。 请注意“构建目标”部分下的注释。 请参阅此超级用户问题以在Visual Studio中嵌入命令提示符。 You should run it in the Visual Studio Command Prompt, not in the Command Window in Visual Studio. Notice the note under the "Building the Target" se ...
  • 我发现了问题。 这是由于延伸“我在哪里”。 我的扩展程序可用于Visual Studio 2010.这不适用于VS 2012.我做了一个hack以便它可以安装在VS 2012上。这导致了这个问题。 我禁用了这个扩展,现在一切正常。 I found the problem. It was due to a extension "Where Am I". Where Am I extension is available for Visual Studio 2010. This is not available ...
  • 请参阅使用DebuggerDisplay属性 如果您通过属性标记了类: [DebuggerDisplay("x = {X} y = {Y}")] public class MyClass { public int X { get; private set; } public int Y { get; private set; } } Watch窗口的Value列中显示的输出如下所示: x = 5 y = 18 See Using DebuggerDisplay Attribute If yo ...
  • 我试图重现您的问题并找到以下内容: 监视窗口似乎使用您在代码中引用的命名空间(通过using )。 如果您不在代码文件中使用linq(和System.Linq命名空间),则监视窗口无法找到扩展名。 如果你有using System.Linq; 并在代码中使用该命名空间中的内容,监视窗口将查找并执行linq扩展。 (如果不使用System.Linq的任何System.Linq ,则会优化引用,因此在运行时不会加载此程序集,并且调试程序无法使用它)。 I tried to reproduce your prob ...
  • 此链接还指示调试符号引擎存在使用虚拟基类进行多重继承的问题。 但是如果你只是想要帮助调试,为什么不在类A上添加一个辅助函数来获得一个D指针(如果可用)。 你可以看pB-> GetMyD()。 class D; class A { ... D* GetMyD(); ... } class D... D* A::GetMyD() { return dynamic_cast(this); } 这将把指针算术留给编译器。 This link also indicate ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。