Home  >  Article  >  Backend Development  >  PHP100视频教程第11讲 准确代码

PHP100视频教程第11讲 准确代码

WBOY
WBOYOriginal
2016-06-13 10:37:57835browse

PHP100视频教程第11讲 正确代码
conn.php 文件
$conn = @ mysql_connect("localhost", "root", "") or die("数据库链接错误");
mysql_select_db("newdb", $conn);
mysql_query("set names 'GBK'"); //使用GBK中文编码;
?>

add.php 文件
include ("conn.php");
if(isset($_POST['submit']) && $_POST['submit']) //吧if($_post['submit'])替换矫正Notice: Undefined index: submit in 错误
{
$sql_add="insert into message (id,user,title,content,lastdate) values ('','$_POST[user]','$_POST[title]','$_POST[content]',now())";
mysql_query($sql_add);
echo "发表成功";
}
?>


用户:

  标题:

  内容:

 

list.php 文件
include("conn.php");
?>

    $sql_list="SELECT * FROM message order by id desc";
  $query=mysql_query($sql_list);
  while($row=mysql_fetch_array($query)){
  ?>
 
//$row[]里面的参数用单引号扣起来
 
 
 
 
 
  }
  ?>
标题:=$row['title']?> 用户:=$row['user']?>
内容:=$row['content']?>


------解决方案--------------------
你有什么问题呀。。。不明白你问的。
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn