php连接mysql数据库

  作者:会飞的

php连接mysql数据库<?php$con = mysql_connect("localhost","username","password");if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db("my_database", $con);$result = mysql_quer

php连接mysql数据库

<?php

$con = mysql_connect("localhost","username","password");

if (!$con)

  {

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

  }


mysql_select_db("my_database", $con);


$result = mysql_query("SELECT * FROM table_name");


while($row = mysql_fetch_array($result))

  {

  echo $row['id'] . " " . $row['name'];

  echo "<br />";

  }


mysql_close($con);

?>


有用  |  无用

猜你喜欢