php为什么向mysql插入不进数据啊,mysql没问题 5
gzhaopian里都添加进照片了,但是goods还是空的book数据库已经建立好了<?phpsession_start();$db=mysql_connect("loc...
gzhaopian里都添加进照片了,但是goods还是空的
book数据库已经建立好了
<?php
session_start();
$db=mysql_connect("localhost","root","123");
//创建数据库
$csh="use book";
mysql_query($csh,$db);
//选择数据库
mysql_select_db("book",$db);
//创建数据表
$csh_s="create table goods(ID int,jiage int,shuliang int,mingcheng char(20),gzhaopian char(100))";
mysql_query($csh_s,$db);
$_SESSION['goodsid']=1;
echo "数据库添加完成!";
?>
添加商品:<br>
<form action=tjgoods.php method=post enctype="multipart/form-data">
名称:<input name=mc type=text><font color=red>*</font><br>
数量:<input name=sl type=text><font color=red>*</font><br>
价格:<input name=jg type=text><font color=red>*</font><br>
上传图片:<input type=file name="gzp"><font color=red>*</font><br>
<input type=submit value=提交>
</form>
<?php
session_start();
$gid=$_SESSION['goodsid'];
$goodsid++;
$mingcheng=$_REQUEST["mc"];
$shuliang=$_REQUEST["sl"];
$jiage=$_REQUEST["jg"];
$gname=$_FILES["gzp"]["name"];
$gtemp=$_FILES["gzp"]["tmp_name"];
move_uploaded_file($gtemp,"gzhaopian/".$gname);
$db=mysql_connect("localhost","root","123");
mysql_select_db("book",$db);
$sql="insert into goods values('".$gid."','".$jiage."','".$shuliang."','".$mingcheng."','$cname')";
$r=mysql_query($sql,$db);
header("Location:sellerindex.php");
?>
求大神找错 展开
book数据库已经建立好了
<?php
session_start();
$db=mysql_connect("localhost","root","123");
//创建数据库
$csh="use book";
mysql_query($csh,$db);
//选择数据库
mysql_select_db("book",$db);
//创建数据表
$csh_s="create table goods(ID int,jiage int,shuliang int,mingcheng char(20),gzhaopian char(100))";
mysql_query($csh_s,$db);
$_SESSION['goodsid']=1;
echo "数据库添加完成!";
?>
添加商品:<br>
<form action=tjgoods.php method=post enctype="multipart/form-data">
名称:<input name=mc type=text><font color=red>*</font><br>
数量:<input name=sl type=text><font color=red>*</font><br>
价格:<input name=jg type=text><font color=red>*</font><br>
上传图片:<input type=file name="gzp"><font color=red>*</font><br>
<input type=submit value=提交>
</form>
<?php
session_start();
$gid=$_SESSION['goodsid'];
$goodsid++;
$mingcheng=$_REQUEST["mc"];
$shuliang=$_REQUEST["sl"];
$jiage=$_REQUEST["jg"];
$gname=$_FILES["gzp"]["name"];
$gtemp=$_FILES["gzp"]["tmp_name"];
move_uploaded_file($gtemp,"gzhaopian/".$gname);
$db=mysql_connect("localhost","root","123");
mysql_select_db("book",$db);
$sql="insert into goods values('".$gid."','".$jiage."','".$shuliang."','".$mingcheng."','$cname')";
$r=mysql_query($sql,$db);
header("Location:sellerindex.php");
?>
求大神找错 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询