我正在尝试使用PHP和mysql将数据插入数据库,但我的查询没有运行 [英] I'm trying to insert data into database using PHP and mysql but my query isn't running

查看:85
本文介绍了我正在尝试使用PHP和mysql将数据插入数据库,但我的查询没有运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用php和mysql将数据插入数据库,但我的查询未运行。我必须使用php和mysql将数据插入到注释表中这里是我的代码。如果有任何错误请告诉我。



 <  < span class =code-leadattribute> pre  >  if(isset($ _ POST ['submit-comment']))
{
$ cs_name = $ _POST ['full-name'];
$ cs_email = $ _POST ['email'];
$ cs_website = $ _POST ['website'];
$ cs_comment = $ _POST ['comment'];
$ cs_date = time();
if(空($ cs_name)或空($ cs_email)或空($ cs_comment))
{
echo< script type =' text / javascript' > swal({title: ' Opps!',text:' 你必须填写所有(*)字段!',imageUrl:' images / info.png'}); < / script > ;
}
else
{
$ cs_query =INSERT INTO`comments`(`id`,`date`,`name`,`username`,`post_id`,` email`,`website`,`image`,`comment`,`status`)VALUES(NULL,$ cs_date,$ cs_name,user,$ post_id,$ cs_email,$ cs_website,NULL,$ cs_comment,pending);
$ cs_run = mysql_query($ cs_query);
if($ cs_run)
{
echo< script type =' text / javascript> setTimeout(function(){swal(' Good job!', '您的 Commnet Submited 等待 对于 Approvel!' , 'success')}, 100);< / script > ;
}
其他
{
echo
< script type = ' text / javascript'> swal({title:' Opps!',text:' 您的Commnet未被提交!',imageUrl:' images / delete.png'}); < < span class =code-keyword> / script > ;
}
}
}
?>





我是什么尝试过:



i已经尝试但没有得到我想要的答案。

解决方案

_POST ['submit-comment']))
{


cs_name =


_POST ['full-name'];

i'm trying to insert data into database using php and mysql but my query isn't running. i have to insert data into comments table using php and mysql here is my code. if there is any errors please tell me.

<pre>if(isset($_POST['submit-comment']))
                {
                    $cs_name = $_POST['full-name'];
                    $cs_email = $_POST['email'];
                    $cs_website = $_POST['website'];
                    $cs_comment = $_POST['comment'];
                    $cs_date = time();
                    if(empty($cs_name) or empty($cs_email) or empty($cs_comment))
                    {
                        echo "<script type='text/javascript'>swal({   title: 'Opps!',   text: 'You Have To Fill All (*) Fields!',   imageUrl: 'images/info.png' });</script>";
                    }
                    else
                    {
                        $cs_query = "INSERT INTO `comments`(`id`, `date`, `name`, `username`, `post_id`, `email`, `website`, `image`, `comment`, `status`) VALUES (NULL,$cs_date,$cs_name,user,$post_id,$cs_email,$cs_website,NULL,$cs_comment,pending)";
                        $cs_run = mysql_query($cs_query);
                        if($cs_run)
                        {
                            echo "<script type='text/javascript>setTimeout(function () { swal('Good job!', 'Your Commnet Has Been Submited Waiting For Approvel!', 'success')}, 100);</script>";
                        }
                        else
                        {
                            echo "<script type='text/javascript'>swal({   title: 'Opps!',   text: 'Your Commnet Not has Been Submited!',   imageUrl: 'images/delete.png' });</script>";
                        }
                    }
                }
              ?>



What I have tried:

i have tried but not get the answer i want.

解决方案

_POST['submit-comment'])) {


cs_name =


_POST['full-name'];


这篇关于我正在尝试使用PHP和mysql将数据插入数据库,但我的查询没有运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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