留言板问题求助
先问一个关于乱码的问题,
在my.ini中设置了 [client] default-character-set=utf8 [mysqld] default-character-set=utf8 然后重启wamp,phpmyadmin就连接不上了,就是#2002 那个套接字错误提示,然后我就把my.ini刚做的修改又改了回去,还是连接不上,(我把修改撤销了应该可以了呀??问题1)最后把localhost改为127.0.0.1 才恢复正常
问题二: 上述操作之后
最后问题
1、conn文件
<?php<br /> $conn = mysql_connect("localhost","root","") or die("Can't connect database: ".mysql_error());<br /> if($conn)<br /> echo "链接成功!";<br /> mysql_select_db("liuyan");<br /> mysql_query("set names 'gbk'");<br /> ?>
<form name = "msgform" method = "post" action = "write.php" enctype = "multipart/form-data" onsubmit = "return checkMessage()"><br /> //javascript略去了<br /> <table width = "64%" border = "0" cellspacing = "1" cellpadding = "3" bgcolor = "#66CCFF" align = "center"><br /> <tr><br /> <td width = "48%">用 户:<br /> <input type = "txet" name = "username"><br /> </td><br /> <br /> </tr><br /> <br /> <tr><br /> <td colspan = "2">标 题:<br /> <input type = "text" name = "title" size = "60" maxlength = "50"><br /> </td><br /> </tr><br /> <tr><br /> <td colspan = "2"><br /> <textarea name = "content" rows = "10" cols = "100"></textarea><br /> </td><br /> </tr><br /> <tr><br /> <td><br /> <div align = "right"><br /> <input type = "submit" name = "sub" value = "提交"><br /> </div><br /> </td><br /> <td><br /> <input type = "reset" name = "Rewrite" value = "重写"><br /> </td><br /> </tr><br /> <br /> </table><br /> </form>
<?php <br /> include("conn.php");<br> if(isset($_POST['username'])){<br> $username = $_POST['username'];<br> $title = $_POST['title'];<br> $content = $_POST['content'];<br> $sql = "insert into easy values('$username','$title','$content',now())";<br> mysql_query($sql) or die("插入失败: ".mysql_error());<br> }<br> ?><br> <?php <br /> include("conn.php");<br> $rowsPerPage = 10;<br> $row = mysql_fetch_array(mysql_query("select count (*) as c from easy")); //查询总记录数...这点书上看的,不太懂,求解释<br> $rows = $row['c']; //得到记录数<br> <br> /* <br> $a = "select * from easy";<br> $b = mysql_query($a);<br> $rows = mysql_num_rows($b);<br> 这个可以么? 另外这个和上面那个有什么区别?? <br> */<br> <br> $pages = ceil($rows/$rowsPerPage); //计算页数 <div class="clear"> </div>