12.6.07 mysql 5.0学习手记(持续更新)
版权声明:原创作品,谢绝转载!否则将追究法律责任。 |
12.06.07
参考书籍:
《mysql 5权威指南 》
按照书中所示,apache、php 可以安装成功,但联接不能成功,故,使用appserv集成包进行安装,成功,mysql单独安装为5.0版本
perl不可使用命令>ppm (每次使用出现cgi窗口,可能由于active perl版本问题造成的)
在进行perl安装测试时,书中出现严重错误,p24 命令修正:
#usr/bin/perl -w
print "hello world\n"; "please hit Return to end the program!"; $wait_for_return=<STDIN>; 按以上修改可以通过测试
======================================================
=====================================
12.08.07
1> 使用mysql数据库时,有时会反馈 "ERRO 1064<42000>"错误,这个错误提示的出现通常是由于输入的命令格式或单词有误,所以认真核对一下命令,通常都可以解决
exp. > create 错误拼写为 .>creat
2>在创建mysql学习库时,可以用.>create database test_XXX; 进行创建
因为:根据mysql访问控制机制默认设置,任何用户都有权在本地计算机上使用以单词“test”开始的名字来创建新的数据库,<此方法适用于无数据库管理员权限的操作者>
缺点:本地计算机任何一位用户都可以编辑、修改和删除这种名字类型的数据库
3>代码,由于此书没有光盘,故代码只能从网络索取,为方便学习,按进度将代码附上
P48 vote.html->
<!doctype html public "-//w3c//dtd html 4.0//en">
<!-php/vote/vote.html-> <html> <head> <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"/> <title>Mysql-poll</title> </head> <body> <h2>Mysql-poll</h2> <p><b>what is your favorite
programming language for developing mysql applications?</b></p> <from method="POST" action="results.php">
<p> <input type="radio" name="vote" value="1"/>c/c++ <br /> <input type="radio" name="vote" value="2"/>java <br /> <input type="radio" name="vote" value="3"/>perl <br /> <input type="radio" name="vote" value="4"/>php <br /> <input type="radio" name="vote" value="5"/>asp/vb/vba <br /> <input type="radio" name="vote" value="6"/>another </p> <p><input type="submit" name="submitbutton" value="ok" /></p> </from> <p>Go directly to the <a href="results.php">result</a>.</p> </body> </html> P51 results.php
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<!-php/vote/results.php-> <html> <head> <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1" /> <title>Survey Result</title> </head> <body> <h2>Survey Result</h2> <?php $mysqlhost="localhost";
$mysqluser="root"; $mysqlpasswd=""; $mysqldbname="test_vote"; //create connection to the database $link= @mysql_connect(mysqlhost,$mysqluser,$mysqlpasswd); if($link==FALSE) { echo"<p><b>Unfortunately,a connection to the database cannot be made.Therefore, the results cannot be displayed at this time please try again later.</b></p> </body></html>\n"; exit(); } mysql_select_db($mysqldbname); //if questionnaire data are available: //evaluate+store function array_item($ar,$key) { if(array_key_exists($key,$ar))return($ar[$key]); return(''); } $submitbutton=array_item($_POST,'submitbutton'); $vote=array_item($_POST,'vote'); if($submitbutton=="OK") { if($vote>=1 && $vote<=6) { mysql_query( "INSERT INTO votelanguage (choice)VALUES($vote)"); } else{ echo"<p>Not a valid selection.Please vote again.Back to <a href=\"vote.html\">questionnaire</a>.</p> </body></html>\n"; exit(); } } //DISPLAY results echo "<p><b>What is your favorite programming language for developing mysql applications?</b></p>\n"; //number of vates cast $result = mysql_query("SELECT COUNT(choice) FROM votelanguage"); $choice_count=mysql_result($result,0,0); //percentages for the individual voting categories if($choice_count==0) { echo"<p>$choice_count individuals have thus far taken part in this survey:</p>\n"; $choicetext=array("","c/c++","java","perl","php","vb/vba","andere"); print("<p><table>\n"); for($i=1;$i<=6;$i++) { $result=mysql_query( "SELECT COUNT(choice) FROM votelanguage". "WHERE choice=$i"); $choice[$i]=mysql_result($result,0,0); $percent=round($choice[$i]/$choice_count*10000)/100; print("<tr><td>$choicetext[$i]:</td>"); print("<td>$percent % </td></tr>\n"); } print("</table></p>\n"); } ?> </body> </html> 本文出自 “Keith” 博客,谢绝转载! 本文出自 51CTO.COM技术博客 |


keith
博客统计信息
热门文章
最新评论
友情链接