The content of this article is about php operating mysql, which has certain reference value. Now I share it with everyone. Friends in need can refer to it
header("Content-type: text/html; charset=utf-8"); $db_config = array( "host"=>"localhost", "db_user"=>"root", "db_password"=>"hxsbhxsb", "db_name"=>"chenchen" ); $link = @mysql_connect($db_config["host"],$db_config["db_user"],$db_config["db_password"]); if($link){ // echo "数据库连接成功!"; }else{ die("数据库连接失败,请与管理员联系!"); } mysql_select_db($db_config["db_name"]); mysql_query("set names utf8"); $res = mysql_query("select * from tab3"); if($res){ $row = mysql_fetch_row($res); var_dump($row); $row = mysql_fetch_row($res); var_dump($row); }else{ echo "错误信息".mysql_error(); }
mysql_num_rows(result) //Return the result set Number of rows
mysql_num_fields(result) //Returns the number of columns in the result set
mysql_field_name(result, $i) //Returns the name of the i-th field in the result set
Related recommendations:
Several ways to convert PHP strings into PHP arrays
Sharing of PHP commands to operate redis
The above is the detailed content of About php operating mysql. For more information, please follow other related articles on the PHP Chinese website!