楼主的代码...........试试下面的if (!isset($_POST["isbn"])&& !!isset($_POST["author"]&&!!isset($_POST["title"]&&!!isset($_POST["price"])
{
echo "You have not entered all the required details.<br>"."please go back and try again";
exit;
}
$isbn=addslashes ($isbn);
$author=addslashes ($author);
$title =addslashes ($title);
$price=doubleval ($price);
@$db=mysql_pconnect("localhost","root",""); //确保这里你的数据库server和用户名无错
if (!$db)
{
echo "Error:Could not connect to database,Please try again later.";
exit ;
}
mysql_select_db("books");
$query="insert into book values('".$isbn."','".$author."','".$title."','".$price."')"; echo $query //输出sql 用于调试if (mysql_query($query))
echo mysql_affected_rows()."book inserted into database";
?>
{
echo "You have not entered all the required details.<br>"."please go back and try again";
exit;
}
$isbn=addslashes ($isbn);
$author=addslashes ($author);
$title =addslashes ($title);
$price=doubleval ($price);
@$db=mysql_pconnect("localhost","root",""); //确保这里你的数据库server和用户名无错
if (!$db)
{
echo "Error:Could not connect to database,Please try again later.";
exit ;
}
mysql_select_db("books");
$query="insert into book values('".$isbn."','".$author."','".$title."','".$price."')"; echo $query //输出sql 用于调试if (mysql_query($query))
echo mysql_affected_rows()."book inserted into database";
?>
解决方案 »
- MySql死锁问题
- oracle替换成MySQL,c链接库proc转换的问题
- 跪求InnoDB英手册
- 各位大侠!问一个关于MySql基础问题!
- mysql 统计分组
- 能否使用if产生的变量加上一个字段值作为order by的条件??
- 请问,postgreSql装在windows下,如何打开postgreSql对多字节语言的支持?
- 这个Sql语句怎么写?
- mysql数据库文件拷过来了,怎么还原
- 这个怎么解决 网上的那些都试过了 具体一点
- 何为identifying relation,Non-identifying relation,informative relation?
- mySQL安装成功,但不会使用@!@
do it step by step when you write source code.
The work flow should be1. write the static html code
2. get the posted data by php after submiting the form.
$isbn=addslashes($_POST['isbn']);
.....
3. write an additional php file to only connect to mysql
print a msg for getting connection
4. embed the connection code to the main php file, or
simply include it
5. write more statement for your dababase handling stuff..