myAdBanner

2013年9月13日 星期五

自動連線網路磁碟

net use t: \\user-PC\share /user:share 12345678

不允許使用多於一個使用者名稱的相同使用者有多個連線到一個伺服器或公用資源.......

不允許使用多於一個使用者名稱的相同使用者有多個連線到一個伺服器或公用資源.......
依序使用下列方法解看看:
1. 先查看一下我的電腦, 看是否有 \\192.168.0.10\e$ 的 網路磁碟機連線.
2. 刪除連線磁碟 net use \\172.17.16.17\e$ /delete
3. 如果還是不行呢! 假設您是用\\IP\資料夾連線或是設定連線磁碟機,嘗試改用\\主機名稱\資料夾,不同就反之。

2013年9月6日 星期五

backup_tables

< ?php 
backup_tables('localhost','root','xxxxxxx','dbname');

/* backup the db OR just a table 
$hostname 主機名稱
$username 帳號
$password 密碼
$dbname   資料庫名稱
*/

function backup_tables($hostname,$username,$password,$dbname,$tables = '*')
{
 
 $link = mysql_connect($hostname,$username,$password);
 mysql_select_db($dbname,$link);
 
 //get all of the tables
 if($tables == '*')
 {
  $tables = array();
  $result = mysql_query('SHOW TABLES');
  while($row = mysql_fetch_row($result))
  {
   $tables[] = $row[0];
  }
 }
 else
 {
  $tables = is_array($tables) ? $tables : explode(',',$tables);
 }
 
 //cycle through
 foreach($tables as $table)
 {
  $result = mysql_query('SELECT * FROM '.$table);
  $num_fields = mysql_num_fields($result);
  
  $return.= 'DROP TABLE '.$table.';';
  $row2 = mysql_fetch_row(mysql_query('SHOW CREATE TABLE '.$table));
  $return.= "\n\n".$row2[1].";\n\n";
  
  for ($i = 0; $i < $num_fields; $i++) 
  {
   while($row = mysql_fetch_row($result))
   {
    $return.= 'INSERT INTO '.$table.' VALUES(';
    for($j=0; $j<$num_fields; $j++) 
    {
     $row[$j] = addslashes($row[$j]);
     $row[$j] = ereg_replace("\n","\\n",$row[$j]);
     if (isset($row[$j])) { $return.= '"'.$row[$j].'"' ; } else { $return.= '""'; }
     if ($j<($num_fields-1)) { $return.= ','; }
    }
    $return.= ");\n";
   }
  }
  $return.="\n\n\n";
 }
 
 //save file
 $handle = fopen('db-backup-'.time().'-'.(md5(implode(',',$tables))).'.sql','w+');
 fwrite($handle,$return);
 fclose($handle);
}
? >

php 連接 mssql

我的程式
<?php
//mssql.secure_connection = On
// Need to upload ntwdblib.dll from net

$myServer = ".\SQLEXPRESS"; // host/instance_name
$myUser = "sa"; // username
$myPass = "xxxxxxxx"; // paasword
$myDB = "mydb"; // database name

// connection to the database
$dbhandle = mssql_connect($myServer, $myUser, $myPass)
or die("Couldn’t connect to SQL Server on $myServer");

// select a database to work with
$selected = mssql_select_db($myDB, $dbhandle)
or die("Couldn’t open database $myDB");

echo "You are connected to the " . $myDB . " database on the " . $myServer . ".";

$query = "SELECT top 10 * FROM Account"; // your database query
$result = mssql_query($query);
while($row = mssql_fetch_assoc($result))
{
print_r($row);
}
// close the connection
mssql_close($dbhandle);

?>

在連接 mssql 時出現這個問題
“Warning mssql_connect()[function.mssql-connect]: Unable to connect to server:”

解決方法
1.修改 php.ini 打開php.ini
找到 ;extension=php_mssql.dll
打extension=php_mssql.dll 前面的 “;” 刪除便可以了

2.下載 ntwdblib.dll
之後把他複製/取代 你電腦上的
Apache/bin/ntwdblib.dll 和 php/ntwdblib.dll

3. Apache Restart

再測就OK了

2013年8月28日 星期三

先加上這一段

















再貼程式碼
這裡貼上程式碼

brush 標籤如下
Brush name         Brush aliases             File name 
ActionScript3      as3, actionscript3        shBrushAS3.js 
Bash/shell         bash, shell               shBrushBash.js 
ColdFusion         cf, coldfusion            shBrushColdFusion.js 
C#                 c-sharp, csharp           shBrushCSharp.js 
C++                cpp, c                    shBrushCpp.js 
CSS                css                       shBrushCss.js 
Delphi             delphi, pas, pascal       shBrushDelphi.js 
Diff               diff, patch               shBrushDiff.js 
Erlang             erl, erlang               shBrushErlang.js 
Groovy             groovy                    shBrushGroovy.js 
JavaScript         js, jscript, javascript   shBrushJScript.js 
Java               java                      shBrushJava.js 
JavaFX             jfx, javafx               shBrushJavaFX.js 
Perl               perl, pl                  shBrushPerl.js 
PHP                php                       shBrushPhp.js 
Plain              Text plain, text          shBrushPlain.js 
PowerShell         ps, powershell            shBrushPowerShell.js 
Python             py, python                shBrushPython.js 
Ruby               rails, ror, ruby          shBrushRuby.js 
Scala              scala                     shBrushScala.js 
SQL                sql                       shBrushSql.js 
Visual Basic       vb, vbnet                 shBrushVb.js 
XML                xml,xhtml,xslt,html,xhtml shBrushXml.js 

如果是php 記得要把? 變成?全形
不然會出錯
<?php
asdf
asdf
asdf
?>

2013年8月26日 星期一

正則式 取出 { } 裡的文字

<?php
$text='{A}fgfgfhf{bb}gdfdd/***4{CC}fs';   

preg_match_all('|{(.+?)}|is', $text, $match);
print_r($match);  
?>