在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>
解决方案 »
- ereg问题
- 这样的写法那里出问题了,谢谢,新手
- 这样写function有问题不
- 请帮忙把这段小asp程序翻译成php的
- 从CVS下载PHP手册后,怎么编译?
- 高手帮帮我!请帮我解释下面的代码好吗?$temp=explode(",",$songid);
- 有没有研究过phpGroupWare的兄弟??
- 请问那里可以下载 win2000 server/IIS 的安装版本的php,,急,(在线等待)
- 怎么样使点击按钮域后另打开一个窗口(就是另外打开一个窗口,不是进入本窗口页面内),以便PHP执行。
- PHP 只允许指定域名访问的代码
- 使用这种方法如果每天增加1000条数据会不会怠慢
- 用过discuz的朋友进来看看。
$sql="select * form message";改成:$sql="select * from message";基础的东西要掌握好