在php100下载了一些PHP视频教程。
然后自己买一本PHP的书籍。
学习了半个多月不过现在遇到问题了
请大家帮一下我。
conn.php链接数据库无问题。
add.php插入数据无问题
list.php无法从数据库读取数据
源代码如下1.conn.php<?php
$conn = @ mysql_connect("localhost", "root", "") or die("数据库链接错误");
mysql_select_db("bbs", $conn);
mysql_query("set names 'GBK'"); //使用GBK中文编码;?>
2.add.php<?php
include("conn.php");//引入连接数据库文件
if ($_POST['submit']){//当用户按下发布留言
$sql="insert into message(id,user,title,content,lastdate)values('','$_POST[user]','$_POST[title]','$_POST[content]',now())";
//将提交内容到MYSQL
mysql_query($sql);
echo "留言发表成功";
//$del="DELETE FROM `bbs`.`message` WHERE `message`.`id` = 13 LIMIT 1";
//mysql_query($del);}
?>
<html>
<head>
<title>欢迎来到我的留言板</title>
</head>
<body>
<form action="add.php" method="post">
用户:<input type="text" size"10" name="user"/><br/>
标题:<input type="text" name="title"/><br/>
内容:<textarea name="content"></textarea><br/>
<input type="submit" name="submit" value="发布留言"/>
</form>
</body>
</html>
3.list.php<?php
include ("conn.php");?><table width=500 border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#add3ef">
<?php
$sql="select * form message";
$query=mysql_query($sql);
while ($row=mysql_fetch_array($query)){
?>
<tr bgcolor="#eff3ff">
<td>标题:<?=$row[title] ?> 用户:<?= $row[user] ?></td>
</tr>
<tr bgColor="#ffffff">
<td>内容:<?= $row [content] ?> </td>
</tr>
<?php
}
?>
</table>
然后自己买一本PHP的书籍。
学习了半个多月不过现在遇到问题了
请大家帮一下我。
conn.php链接数据库无问题。
add.php插入数据无问题
list.php无法从数据库读取数据
源代码如下1.conn.php<?php
$conn = @ mysql_connect("localhost", "root", "") or die("数据库链接错误");
mysql_select_db("bbs", $conn);
mysql_query("set names 'GBK'"); //使用GBK中文编码;?>
2.add.php<?php
include("conn.php");//引入连接数据库文件
if ($_POST['submit']){//当用户按下发布留言
$sql="insert into message(id,user,title,content,lastdate)values('','$_POST[user]','$_POST[title]','$_POST[content]',now())";
//将提交内容到MYSQL
mysql_query($sql);
echo "留言发表成功";
//$del="DELETE FROM `bbs`.`message` WHERE `message`.`id` = 13 LIMIT 1";
//mysql_query($del);}
?>
<html>
<head>
<title>欢迎来到我的留言板</title>
</head>
<body>
<form action="add.php" method="post">
用户:<input type="text" size"10" name="user"/><br/>
标题:<input type="text" name="title"/><br/>
内容:<textarea name="content"></textarea><br/>
<input type="submit" name="submit" value="发布留言"/>
</form>
</body>
</html>
3.list.php<?php
include ("conn.php");?><table width=500 border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#add3ef">
<?php
$sql="select * form message";
$query=mysql_query($sql);
while ($row=mysql_fetch_array($query)){
?>
<tr bgcolor="#eff3ff">
<td>标题:<?=$row[title] ?> 用户:<?= $row[user] ?></td>
</tr>
<tr bgColor="#ffffff">
<td>内容:<?= $row [content] ?> </td>
</tr>
<?php
}
?>
</table>
解决方案 »
- mb_send_mail发邮件时bcc的写法
- 如何实现全站访问任何页面都是index.php一个文件的呢?
- 要求:输入一个英文方式的数字,输出中文方式的数字表达方式。
- 如何实现这个???求助!
- 菜鸟求助 PHP怎样得到一个数组中的指定键名的值?
- 求大神帮忙,CI访问restful问题
- 请教,SQL语句里如何运行PHP函数对查询的结果进行限制?
- 租的空间能不能实现URL的重写呢?
- 用apache_2.0.55-win32版本的请进,在设置的时候有点问题请教!
- 要开发网页都要用到什么工具?现在PHP。ASP。我不知道用什么好?
- 使用这种方法如果每天增加1000条数据会不会怠慢
- 用过discuz的朋友进来看看。
$sql="select * form message";改成:$sql="select * from message";基础的东西要掌握好