php数据写入mysql,写不进去(急)
<?php/*purchase_success.php*/include("config.php");session_start();$aid=$_SESSION["ai...
<?php
/*purchase_success.php*/
include("config.php");
session_start();
$aid=$_SESSION["aid"];/*aid*/
$user_name=$_SESSION["name"];
$count=$_POST["count"];
$total=$_POST["total"];
$alltotal=$_POST["alltotal"];
$title=$_SESSION["title"];
$sellerid=$_SESSION["sellerid"];;
$seller_name=$_SESSION["seller_name"];;
$url=$_SESSION["url"];
$datetime=date("Y年n月j日 H:i:s");
$db=mysql_connect("localhost","zm","123456") or die("连接数据库失败");
mysql_select_db("order",$db) or die("选择数据库失败");
mysql_query("SET NAMES 'gbk'");
$lashou_sql="insert into lashou_order(orderid,aid,user_name,sellerid,seller_name,datetime,count,total,alltotal,title,url) values(NULL,'$aid','$user_name','sellerid','$seller_name','$datetime','$count','$total,'$alltotal','$title','$url');";
$result=mysql_query($lashou_sql);
if(!$result)
echo "insert data failed--lashou";
$sql="insert into daohang_order(orderid,aid,user_name,sellerid,seller_name,datetime,count,total,alltotal,title,url) values(NULL,'$aid','$user_name','$sellerid','$seller_name','$datetime','$count','$total','$alltotal','$title','$url')";
$result=mysql_query($sql);
if(!$result)
echo "insert data failed--dahang";
echo ("<script type='text/javascript'> alert('完成订单!');location.href='index_login.php';</script>");
而这段php就可以写进数据库?<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title> 付款台</title>
</head>
<body>
<center>
<p> </p>
<p> </p>
<form method="post" action="../purchase_success.php">
<table width="500" height="241" border="0" cellpadding="0" cellspacing="0">
<tr align="center">
<td colspan="2" bgcolor="transparent">付款台</td>
</tr>
<tr bgcolor="transparent">
<td width="137" align="center">单价</td>
<td width="363"><input name="count" type="text" value="25"></td>   
<td width="137" align="center">数量</td>
<td width="363"><input name="total" type="text"></td>
</tr>
<tr align="center" >
<td colspan="2"><input type="submit" name="submit" value="确认"></td>
</tr>
为什么?? 展开
/*purchase_success.php*/
include("config.php");
session_start();
$aid=$_SESSION["aid"];/*aid*/
$user_name=$_SESSION["name"];
$count=$_POST["count"];
$total=$_POST["total"];
$alltotal=$_POST["alltotal"];
$title=$_SESSION["title"];
$sellerid=$_SESSION["sellerid"];;
$seller_name=$_SESSION["seller_name"];;
$url=$_SESSION["url"];
$datetime=date("Y年n月j日 H:i:s");
$db=mysql_connect("localhost","zm","123456") or die("连接数据库失败");
mysql_select_db("order",$db) or die("选择数据库失败");
mysql_query("SET NAMES 'gbk'");
$lashou_sql="insert into lashou_order(orderid,aid,user_name,sellerid,seller_name,datetime,count,total,alltotal,title,url) values(NULL,'$aid','$user_name','sellerid','$seller_name','$datetime','$count','$total,'$alltotal','$title','$url');";
$result=mysql_query($lashou_sql);
if(!$result)
echo "insert data failed--lashou";
$sql="insert into daohang_order(orderid,aid,user_name,sellerid,seller_name,datetime,count,total,alltotal,title,url) values(NULL,'$aid','$user_name','$sellerid','$seller_name','$datetime','$count','$total','$alltotal','$title','$url')";
$result=mysql_query($sql);
if(!$result)
echo "insert data failed--dahang";
echo ("<script type='text/javascript'> alert('完成订单!');location.href='index_login.php';</script>");
而这段php就可以写进数据库?<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title> 付款台</title>
</head>
<body>
<center>
<p> </p>
<p> </p>
<form method="post" action="../purchase_success.php">
<table width="500" height="241" border="0" cellpadding="0" cellspacing="0">
<tr align="center">
<td colspan="2" bgcolor="transparent">付款台</td>
</tr>
<tr bgcolor="transparent">
<td width="137" align="center">单价</td>
<td width="363"><input name="count" type="text" value="25"></td>   
<td width="137" align="center">数量</td>
<td width="363"><input name="total" type="text"></td>
</tr>
<tr align="center" >
<td colspan="2"><input type="submit" name="submit" value="确认"></td>
</tr>
为什么?? 展开
展开全部
$lashou_sql="insert into lashou_order(orderid,aid,user_name,sellerid,seller_name,datetime,count,total,alltotal,title,url) values(NULL,'$aid','$user_name','sellerid','$seller_name','$datetime','$count','$total,'$alltotal','$title','$url');";
倒数第二个分号去掉。最好把错误提示也放上来
倒数第二个分号去掉。最好把错误提示也放上来
追问
去掉了,还是写不进去……没有任何错误提示……哎……
追答
调试的时候
echo $lashou_sql;
看看语句中的变量有数据没有。
展开全部
在程序上面加上error_reporting("E_ERROR|E_PARSE|E_WARNING");
把 $lashou_sql 和$sql 两个echo 出来 去数据库软件或phpMyadmin只直接运行一下 看看什么情况
如果有错误提示一定要贴出来看看
把 $lashou_sql 和$sql 两个echo 出来 去数据库软件或phpMyadmin只直接运行一下 看看什么情况
如果有错误提示一定要贴出来看看
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你先把那个sql语句在数据库运行下,看能不能出结果,然后再判断别的错误
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询