[英]how to remove this notice while displaying the result in php
我已經在php中使用ODBC連接了sqlserver。 我能夠連接數據庫並對其進行查詢,但是在結果部分中,我沒有得到正確的結果。
我收到此通知:
server connected
Notice: Use of undefined constant CName - assumed 'CName' in
D:\Installations\wamp\www\connectweb\newfile.php on line 21
Turmeric
Notice: Use of undefined constant CName - assumed 'CName' in
D:\Installations\wamp\www\connectweb\newfile.php on line 21
Neem
Notice: Use of undefined constant CName - assumed 'CName' in
D:\Installations\wamp\www\connectweb\newfile.php on line 21
Coriander
Notice: Use of undefined constant CName - assumed 'CName' in
D:\Installations\wamp\www\connectweb\newfile.php on line 21
Almond
這是我的代碼:
<?php
$connect = odbc_connect('ServerDB','sa', 'admin');
if (!$connect) {
die('Something went wrong while connecting to MSSQL');
}
else
echo "server connected";
$query = "SELECT CName FROM dbo.Conc";
$result = odbc_exec($connect, $query);
while(odbc_fetch_row($result)){
$name= odbc_result($result,CName);
echo("$name \n");
}
?>
我是php的新手,我不知道自己被卡在哪里。 dbo.Conc
表具有字段CName
。 我正在使用odbc連接到數據庫。
odbc_result的第二個參數:
正在檢索的字段名稱。 它可以是包含所需字段的列號的整數。 或者它可以是包含字段名稱的字符串。
您需要做的是:
$name= odbc_result($result,'CName');
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.