在虚拟主机,但code未知错误以及运行在本地主机上 [英] Unknown Error on Web Host but code runs well on localhost

查看:99
本文介绍了在虚拟主机,但code未知错误以及运行在本地主机上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚过完一个形式,我的本地主机的工作,这是工作完美,但是当我上传了code到虚拟主机它不工作,因为它应该。它是一种使用PHP,MySQL和JQuery的一个简单的形式。当我点击提交就说明我的自定义错误窗口说,电子邮件是已经注册但问题是,数据库是空的。我把一些code,检查电子邮件中的AJAX部分内,这就是它说(它应该只显示一个数字):

I just had finished a form working in my localhost, it was working perfectly, but by the time I uploaded the code to the web host it wasn't working as it was supposed to. It is a simple form that uses PHP, MySQL and JQuery. When I click on submit it shows my custom error window saying that the email was registered already but the thing is that the database is empty. I put some code inside the ajax part that checks the email and this is what it says (it's supposed to show only a number):


警告:mysql_fetch_assoc():提供的参数不是一个有效的MySQL结果资源 /*/*/public_html/check_user.php 在线 17


Warnings : mysql_fetch_assoc(): supplied argument is not a valid MySQL result resources in /*/*/public_html/check_user.php on line 17

下面是check_user.php:

Here's check_user.php:

<?php
require_once("SqlChromoConnection.php");

// Check if email is not empty in the form
if(isset($_POST['email'])) {

    // create the query
    $sql = "SELECT COUNT(*) AS count
            FROM Users
            WHERE email = '" . trim($_POST['email']) . "'";

    // create object to handle the connection
    $conn = new SqlChromoConnection();
    $conn->getDatabaseConnection();     // establish a connection

    $data = $conn->executeQuery($sql);  // execute query
    $count= mysql_fetch_assoc($data);   // save result in $count
    $exists = $count['count'];      // access only the field 'count'

    $conn->closeConnection();       // close the connection

    echo $exists;

    exit(0);
}

?>

而这里的AJAX部件,检查电子邮件:

And here's the ajax part that checks the email:

if( !re.test(email) || email.indexOf(' ') > 0) {
            message = "Email NOT valid!!!";
            messageDialog("Warning", message, "warning", 2);
            return false;
        } else {
            // use ajax to check if a user has been previously registered
            // using this email
            var valid = false;

            $.ajax(
            {
                url:"check_user.php",   // url that will use
                async: false,
                data:{                  // data that will be sent
                    email:email
                },
                type:"POST",            // type of submision
                dataType:"text",        // what type of data we'll get back
                success:function(data)
                { 
                    window.alert(data);
                    // if check_user returns 0
                    // means that there's no any user registered with that email
                    if(data == 0 ) {
                        valid = true;
                    }
                }
            });

            if(!valid) {
                message = "This email is registered already!";
                messageDialog("Error", message, "error", 2);
                return false;
            }else return true;

        }

正如我所说,code运行良好,在本地主机的时候。

As I said, the code runs well when in localhost.

任何建议将非常AP preciated。

Any suggestions will be really appreciated.

问候。

推荐答案

在添加 @ 您的 mysql_fetch_assoc 它会删除所有的警告来自这一说法。 使用例如 @mysql_fetch_assoc()。

Add @ before your mysql_fetch_assoc it removes all warning comes from this statement. Use like @mysql_fetch_assoc().

这篇关于在虚拟主机,但code未知错误以及运行在本地主机上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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