RFID射頻卡超市購物結算系統問題記錄--寫入卡片時,後台php無法操作資料庫

來源:互聯網
上載者:User

標籤:

後台管理員要給每件商品貼上RF卡作為唯一標識,所以要先給對應的RFID卡中寫入響應的資訊,我這裡為了便於類比示範唯寫入商品編號,價格,名稱這幾個欄位,然後要把已經寫入的商品上傳後台,由後台寫入資料庫中的商品表(Goods)中,其中VB訪問背景代碼如下:

            ‘把寫入卡片的內容上傳伺服器,由伺服器儲存在資料庫中,後期需要修改url等內容            Dim sssa As New WinHttpRequest            Dim urlString As String = "http://mzwapitest.applinzi.com/" + "?" + "name=" + "‘" + GoodsName + "‘"            Console.WriteLine(urlString)            sssa.Open("GET", urlString, False)            sssa.Send()            ‘ 如果返回為字串“OK”, 則顯示寫卡成功標識            If sssa.ResponseText.Length Then                Label6.Text = "商品編碼編碼:" + GoodsNumb + ";商品名稱:" + GoodsName + ";商品價格:" + GoodsPric + "   寫入成功" + sssa.ResponseText            Else                ISO15693_WriteMultipleBlocks(hr, ht, 0, 112, eraseData, eraseData.Count - 1)            End If

 

php後台如下:

<?phpheader("Content-type:text/html;charset = utf-8");$name = $_GET[‘name‘];//$numb = $_GET[‘numb‘];//$price = $_GET[‘price‘];//if ($name=="aaa") {    //echo ‘mazhongwei‘;//}// 連主庫$db = mysql_connect(SAE_MYSQL_HOST_M.‘:‘.SAE_MYSQL_PORT,SAE_MYSQL_USER,SAE_MYSQL_PASS);//$db = mysql_connect(w.rdc.sae.sina.com.cn.‘:‘.3307,ilzy5im2l1w4im2hl13miwmy3ky3l10h1y3l4wkh);// 連從庫// $db = mysql_connect(SAE_MYSQL_HOST_S.‘:‘.SAE_MYSQL_PORT,SAE_MYSQL_USER,SAE_MYSQL_PASS);if ($db) {     mysql_select_db(app_mzwapitest, $db);    $ok = mysql_query(‘insert into Goods(name) values($name)‘);   if($ok){       echo ‘OK‘;   }else{             echo ‘insert error‘;   }        // ...}else {    echo ‘openerror‘;}?>

 

但是在操作過程中總是不能正確串連,後在php操作資料庫的語句後天添加一條語句,用來接收sql操作失敗的提示:

<?phpheader("Content-type:text/html;charset = utf-8");$name = $_GET[‘name‘];//$numb = $_GET[‘numb‘];//$price = $_GET[‘price‘];//if ($name=="aaa") {    //echo ‘mazhongwei‘;//}// 連主庫$db = mysql_connect(SAE_MYSQL_HOST_M.‘:‘.SAE_MYSQL_PORT,SAE_MYSQL_USER,SAE_MYSQL_PASS);//$db = mysql_connect(w.rdc.sae.sina.com.cn.‘:‘.3307,ilzy5im2l1w4im2hl13miwmy3ky3l10h1y3l4wkh);// 連從庫// $db = mysql_connect(SAE_MYSQL_HOST_S.‘:‘.SAE_MYSQL_PORT,SAE_MYSQL_USER,SAE_MYSQL_PASS);if ($db) {     mysql_select_db(app_mzwapitest, $db);    $ok = mysql_query(‘insert into Goods(name) values("$name")‘);   if($ok){       echo ‘OK‘;   }else{      echo mysql_error();       echo ‘insert error‘;   }        // ...}else {    echo ‘openerror‘;}?>

然後看到返回的錯誤資訊為:

Unknown column ‘$name‘ in ‘field list‘insert error

 

在網上查發現原因是:

 

於是在php語句操作mysql的語句進行如下修改

修改前:$ok = mysql_query(‘insert into Goods(name) values($name)‘);修改後:$ok = mysql_query(‘insert into Goods(name) values("$name")‘);

 

 然後就可以了。

RFID射頻卡超市購物結算系統問題記錄--寫入卡片時,後台php無法操作資料庫

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.