Code snippet 工具程式的使用範例

   1: <?php



   2: //$host = "localhost";



   3: $host = "instance19216.db.xeround.com";



   4: $port = "12784";



   5: $db    = "school";



   6: $user    = "perton";



   7: $pass    = "12345";



   8:  



   9: //$conn = mysql_pconnect("mysql:host='instance19216.db.xeround.com:12784';dbname=$db", $user, $pass);



  10: $conn = mysql_pconnect("instance19216.db.xeround.com:12784","perton","12345");



  11:   if (!$conn)



  12:     die('Could not connect: ' . mysql_error());


  13:   mysql_select_db("school");



  14:  



  15:  



  16: $sql = "SELECT * FROM student";



  17: $q     = $conn->query($sql) or die("failed!");



  18:  



  19: while($r = $q->fetch(PDO::FETCH_ASSOC)){



  20:   echo $r['name'] . "<br />";



  21: }



  22: ?>


沒有留言: