#眉標=MySQL、mysqli、PHP #副標=MySQL Server開發應用(5) #大標=PHP的MySQL參數運用 #作者=文/圖 葉建榮 ============= 程式1 "; exit(); } mysqli_query($link,'set names utf8'); function checking($link,$value) { if (function_exists ( 'get_magic_quotes_gpc' )){ if (get_magic_quotes_gpc( )) { echo "執行stripslashes函數()前:".$value."
"; $value = stripslashes($value); echo "執行stripslashes函數()後:".$value."
"; } } if (!is_numeric($value)) { echo "執行mysql_real_escape_string函數()前:".$value."
"; $value = "'" .mysqli_real_escape_string($link,$value) . "'"; echo "執行mysql_real_escape_string函數()後:".$value."
"; } else $value =mysqli_real_escape_string($link,$value); return $value; } ?> ================ ============= 程式2 資料庫連線Procedural "; echo $col2."
"; } mysqli_stmt_close( $stmt );} mysqli_close($link); ?> ================ ===<反灰>============= $stmt = mysqli_prepare($link,"select customerid,companyname from customers where country = ? limit 5" );   ================ ===<反灰>============= mysqli_stmt_bind_param($stmt, "s", $country);   ================ ===<反灰>============= $stmt = mysqli_prepare($link,"select customerid,companyname from customers where country = ? limit 5" ); if ($stmt) { mysqli_stmt_bind_param( $stmt, "s", $country); mysqli_stmt_execute($stmt); mysqli_stmt_bind_result($stmt,$col1,$col2); while (mysqli_stmt_fetch($stmt)) { echo $col1."
"; echo $col2."
"; } ================ ===<反灰>============= mysqli_stmt_close( $stmt );} mysqli_close($link); ================