Home  >  Article  >  Backend Development  >  PHP operation MySql database_PHP tutorial

PHP operation MySql database_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:51:00717browse

//Link database

$conn = @mysql_connect("localhost","root","88888888") or die ("Link Error");
//Solve Chinese garbled characters

mysql_query("set names 'GBK'");

//Open database
mysql_select_db("wordpress",$conn) or die("Open failed");
$sql = "select * from wp_posts";

//Execute sql statement
$result = mysql_query($sql,$conn);

//Loop to print the required parameters
while($row = mysql_fetch_array($result))
{
echo $row[4]."
";//Tested many times, $row[4] can only be an index, not a column name, I am depressed
}

Excerpted from Candle Shadow under the Lamp

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/478232.htmlTechArticle//Link database $conn = @mysql_connect(localhost,root,88888888) or die (link error); / /Solve Chinese garbled characters mysql_query(set names GBK); //Open the database mysql_select_db(wordpres...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn