简体   繁体   English

php脚本离线工作但不能在线工作

[英]php script works offline but doesn't work online

LIVE SAMPLE this is my sample live website实时示例这是我的示例实时网站

The Problem is my code for a "Contact-Us" works fine when i use it offline(wampserver) but when i upload it to my cpanel it doesnt work... i tried almost everything but the alert just sends me the "connection failed" the Connection.php works fine i can connect to the database, the problem seems to be in the INSERT statement.问题是我的“联系我们”代码在我离线使用时工作正常(wampserver)但是当我将它上传到我的 cpanel 时它不起作用......我几乎尝试了所有方法但警报只是向我发送“连接失败" Connection.php 工作正常,我可以连接到数据库,问题似乎出在 INSERT 语句中。 i don't see any problems in my code, because my other "registration" form works just fine online see my sample website.我在我的代码中没有看到任何问题,因为我的其他“注册”表单在线工作正常,请参阅我的示例网站。 there's no error problem on my code because i already cheked the error log:我的代码没有错误问题,因为我已经检查了错误日志:

图像是我在网上的错误日志。里面没有问题。。

    <?php 

include_once 'Connection.php';

if(isset($_POST['btn-index']))
{
 $first_name = $_POST['first_name'];
 $email = $_POST['email'];
 $contact = $_POST['contact'];
 $subject = $_POST['subject'];
 $message = $_POST['workarea'];


$first_name = stripslashes($_REQUEST['first_name']);
$first_name = mysqli_real_escape_string($conn,$first_name);

$email = stripslashes($_REQUEST['email']);
$email = mysqli_real_escape_string($conn,$email);

$contact = stripslashes($_REQUEST['contact']);
$contact = mysqli_real_escape_string($conn,$contact);

$subject = stripslashes($_REQUEST['subject']);
$subject = mysqli_real_escape_string($conn,$subject);

$message = stripslashes($_REQUEST['workarea']);
$message = mysqli_real_escape_string($conn,$message);

$sql = "INSERT INTO `inquiry` (First_Name,Email,Contact,Subj,Message)
VALUES('$first_name','$email','$contact','$subject','$message')";

if($conn->query($sql) === TRUE)
        {
            ?>
            <script>
            alert('Records Submitted!');
            window.location.href='index.php#parent_contacts';
            </script>
            <?php
        }
        else
        {
            ?>
            <script>
            alert('Connection Failed...');
            window.location.href='index.php#parent_contacts';
            </script>
            <?php
        }
$conn->close();
}

//---------FOR ABOUT-US.PHP-------------------------
if(isset($_POST['btn-contact']))
{
 $name = $_POST['name'];
 $email = $_POST['email'];
 $contact = $_POST['contact'];
 $subject = $_POST['subject'];
 $message = $_POST['message'];


$name = stripslashes($_REQUEST['name']);
$name = mysqli_real_escape_string($conn,$name);

$email = stripslashes($_REQUEST['email']);
$email = mysqli_real_escape_string($conn,$email);

$contact = stripslashes($_REQUEST['contact']);
$contact = mysqli_real_escape_string($conn,$contact);

$subject = stripslashes($_REQUEST['subject']);
$subject = mysqli_real_escape_string($conn,$subject);

$message = stripslashes($_REQUEST['message']);
$message = mysqli_real_escape_string($conn,$message);

$sql = "INSERT INTO `inquiry` (First_Name,Email,Contact,Subj,Message)
VALUES('$name','$email','$contact','$subject','$message')";

if($conn->query($sql) === TRUE)
        {
            ?>
            <script>
            alert('Records Submitted!');
            window.location.href='Contact-Us.php';
            </script>
            <?php
        }
        else
        {
            ?>
            <script>
            alert('Connection Failed...');
            window.location.href='Contact-Us.php';
            </script>
            <?php
        }
$conn->close();
}

?>

I finally fixed my problem after re writing my codes.重新编写代码后,我终于解决了我的问题。 turns out the problem was on my SQL Table.. the rows doesn't have collation and all rows turned into "int" didnt know what triggers it on godaddy myphpAdmin but it works fine on my wamp when using my local原来问题出在我的 SQL 表上.. 行没有整理,所有行都变成了“int”,不知道是什么在 Godaddy myphpAdmin 上触发了它,但是当使用我的本地时它在我的 wamp 上运行良好

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM