20110430

win7下 命令列啟動關閉mysql

啟動>
以系統管理員執行CMD,後執行 mysqld。
註:cmd下以系統管理員執行net start window service name才是正確的,直接執行,似乎是運行一個新的服務?無法登入SQL伺服器。
關閉>
任何權限都可以關閉mysql服務,cmd下執行,mysqladmin -u -p shutdown。
註:net stop window service name相等。

20110427

header() and session_start()

使用header()時,要寫在所有網頁輸出"內容"(echo、print...)前,因為所有的輸出都屬於內容裡的,而又在前,所以PHP會強制且你不會知道的先輸出header(),而造成錯誤。另外使用location標頭時,通常會接die()或exit,忽略後面程式。
session_start()也是如此。



function.header
範例

20110422

JFrame 與 Panel的關係

Jframe.setContentPane(new JDesktopPane())
jframe.getContentPane.add(new JDesktopPane())
JFrame.getContentPane
得到的會是jframe它本身的contentpane
所以是在contentpane上面"加入"JDesktopPane
 
JFrame.setContentPane
則是利用JDesktopPane來"取代"jframe的contentpane


20110418

PHP 與 HTML如何傳遞變數

1.用form傳遞 ,$_POST['NAME']變數
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title heretitle>
head>
<body>
//FORM method='post',按下submit後會切換到ootest.php
        //在php中以$_POST["name"]取得其值
         //ex:$_POST["studname"] 
        <form name="form1" method="post" action="ootest.php">
 <input type=text name="studname">
 <input type=submit name="submit" value="enter">
        form>
body>
html>
 
2. URL(http://url/xxx.php?欄位名稱=欄位值&...),$_GET["name"]變數 
<form name="form1" method="get" action="ootest.php">
 <input type=text name="studname">
 <input type=submit name="submit" value="enter">
        form>
3. $_SERVER $_COOKIE $_SESSION變數
 
 http://www.study-area.org/phorum/index.php?topic=32453.0;wap2
http://blog.yam.com/ihy08/article/17825438 

20110415

在使用JDBC時Class.forName(String)的功用

System.out.println(Class.forName("com.mysql.jdbc.Driver").getName());

註冊driver,但是不明白為什麼註解掉也能順利連結資料庫?(似乎跟IDE有關)

實際上
Class.forName("com.mysql.jdbc.Driver");
同等於:
com.mysql.jdbc.Driver driver =new com.mysql.jdbc.Driver();
或
new com.mysql.jdbc.Driver();

預先在JVM載入類別(JAVA是類別實際用到時才會在入記憶體),
所以才寫在連接前,確保DriverManager類別的靜態方法registerDriver
先註冊Driver。

20110414

新增 使用者

grant 權限 on 資料庫名稱.* to 帳號@主機位置 identified by '密碼';
 
grant all on school.* to admin@[localhost,&,IPadd] identified by '12345';

新增完後使用指令flush privileges更新權限

 

Eclipse 掛zend debugger

  http://down.chinaz.com/soft/12394.htm

1. Extract the Zend Debugger package.

2. Locate the ZendDebugger.so (Unix) or ZendDebugger.dll (Windows) file in the directory which
   corresponds to your version of PHP (4.3.x, 4.4.x, 5.0.x, 5.1.x, 5.2.x).

2. Add the following line to your php.ini file:
   Linux and Mac OS X:     zend_extension=
   Windows:                zend_extension_ts=
   Windows non-thread safe: zend_extension=
   (*) The Windows non-thread safe binary is only used with Zend Core 2.0.
 
3. Add the following lines to your php.ini file:
   zend_debugger.allow_hosts=
   zend_debugger.expose_remotely=always
   (*) hopst_ip_addresses are the IPs of the hosts which will be allowed to initiate debug sessions
4. Copy the dummy.php file to your document root directory.
5. Restart your Web server.
要注意ZendDebugger.dll的版本,不然就算路徑正確,PHP也抓不到

php.ini添加以下內容
zend_extension_ts="完整路徑(一定要填路徑)\ZendDebugger.dll"
zend_debugger.allow_hosts=localhost
zend_debugger.expose_remotely=always

http://www.ibm.com/developerworks/library/i-osource13/index.html

eclipse設定

 設定PHP執行檔路徑與設定檔路徑


今天的我


超級愛妳

MySQL phpmyadmin apache PHP 安裝

>安裝MySQL http://dev.mysql.com/downloads/
資料庫位置位於\MySQL\data
安裝過程設定DB管理員帳號密碼

>安裝apache http://www.apache.org/dist//httpd/binaries/win32/
網站根目錄位於\Apache Software Foundation\Apache2.2\htdocs
設定檔\Apache Software Foundation\Apache2.2\conf
port、servername都在設定檔裡改

>安裝PHP      http://php.net/downloads.php
安裝過程指定apache位置
設定檔PHP.ini
檢查一下extension是否正確
我自己會用到curl,mysql,MBSTRING

>連接PHP與apache
在APACHE的設定檔裡
加入
---
#BEGIN PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL
PHPIniDir "C:/program files/PHP/"
LoadModule php5_module "C:/program files/PHP/php5apache2_2.dll"
#END PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL
---

將 php 目錄下的 libmysql.dll 複製到 Apache Server 安裝目錄下的 bin 子目錄
(少此一步驟雖然可以完成整個安裝流程,但是在藉由phpmyadmin的登入畫面時打完sql帳密必定會造成未知的瀏覽器停止)

重啟apache

>安裝phpmyadmin
解壓phpmyadmin到Apache Software Foundation\Apache2.2\htdocs底下
建一個資料夾config在Apache Software Foundation\Apache2.2\htdocs\phpmyadmin\底下連接server http://127.0.0.1/phpmyadmin/setup/index.php
(依照apache設定連接)
依照網頁內容設定phpmyadmin產生設定檔config.inc(在config底下),取出放在上層目錄後,砍掉config資料夾(避免他人更改)。

20110412

MySQL CONSOL 命令

1.連接SQLserver
mysql –h 主機名 –u 用戶名 –p 用戶密碼
mysql -uroot -ppassword

apache http server 下載

http://www.apache.org/dist//httpd/binaries/win32/