新聞中心
php前后臺(tái)數(shù)據(jù)交互是什么意思?
就是通過php鏈接數(shù)據(jù)庫取數(shù)據(jù)再通過php控制數(shù)據(jù)在html顯示,php就是一個(gè)實(shí)現(xiàn)html和數(shù)據(jù)庫交互的一個(gè)橋梁
創(chuàng)新互聯(lián)是一家專業(yè)提供太和企業(yè)網(wǎng)站建設(shè),專注與成都網(wǎng)站建設(shè)、做網(wǎng)站、H5網(wǎng)站設(shè)計(jì)、小程序制作等業(yè)務(wù)。10年已為太和眾多企業(yè)、政府機(jī)構(gòu)等服務(wù)。創(chuàng)新互聯(lián)專業(yè)網(wǎng)站制作公司優(yōu)惠進(jìn)行中。
php判斷數(shù)據(jù)庫是不是連接成功的測試?yán)?/h2>
form action="" method="post"
select name="host"
option value="localhost" selectedlocalhost/option
option value="127.0.0.1"127.0.0.1/option
/select
brbr
user:input type="text" name="user" value=""brbr
pwd :input type="passWord" name="pwd" value=""brbr
input type="submit" value="connent"
input type="reset" value="reset"
/form
?php
error_reporting(~E_ALL);
$host = $_POST['host'];
$user = $_POST['user'];
$pwd = $_POST['pwd'];
if(isset($_POST['host']) isset($_POST['user']) isset($_POST['pwd'])){
if(strlen($host)1 or strlen($user)1 or strlen($pwd)1){
echo "請完善相關(guān)數(shù)據(jù)庫鏈接信息。";
exit(0);
}
$conn = mysql_connect($host, $user, $pwd) or die("Error-數(shù)據(jù)庫連接失敗!");
if($conn){
echo "OK—數(shù)據(jù)庫連接成功!";
}
}
?
php ci 數(shù)據(jù)庫調(diào)用判斷問題.
你在查詢數(shù)據(jù)庫時(shí)沒有給$this-db-where('uname',$id);這里的ID值,所以會(huì)報(bào)錯(cuò),至于輸出的注冊成功是因?yàn)閕f ($user[0]-uid =='')是成立的所以會(huì)有輸出,把$id值是否為空做下判斷,如果為空則不查詢。
function user_select($id)
{
if($id=='') return false;
$this-db-where('uname',$id);
$this-db-select('*');
$query=$this-db-get('user');
return $query-result();
}
PHP 判斷數(shù)據(jù)庫連接
$host='XXX';
$user='XX';
$pass='XXX';
$db='edu';
$conn=@mysql_connect($host,$user,$pass);
if(!$conn){
echo 'script alert("數(shù)據(jù)庫錯(cuò)誤");window.location.href="XX.php";/script';
}
else{
mysql_select_db($db,$conn);
}
mysql_query("SET NAMES UTF8");
標(biāo)題名稱:php與數(shù)據(jù)庫交互判斷 php對數(shù)據(jù)庫的操作
瀏覽地址:http://ef60e0e.cn/article/hgjoce.html