求高手幫小弟我看上這個PHP讀取mysql的介面如何讀取不出資料來?

來源:互聯網
上載者:User
求高手幫我看下這個PHP讀取mysql的介面怎麼讀取不出資料來???
這是建立資料庫的

CREATE TABLE IF NOT EXISTS `tm_comment` (
`playerID` text NOT NULL,
`message` text NOT NULL,
`color` text NOT NULL,
`fontsize` varchar(3) NOT NULL,
`mode` varchar(2) NOT NULL,
`playTime` varchar(4) NOT NULL,
`date` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;






這是寫入介面的


$vid = $_POST['playerID'];
$message =$_POST['message'];
$color =$_POST['color'];
$fontsize =$_POST['fontsize'];
$mode =$_POST['mode'];
$playtime =$_POST['playTime'];
$date =$_POST['date'];
$conn=mysql_connect("localhost", "root", "root");
mysql_query("set names 'utf8'",$conn);
mysql_select_db("ultrax",$conn);
$exec="INSERT INTO `tm_comment` (`playerID`, `message`, `color`, `fontsize`, `mode`, `playTime`, `date`) VALUES ('$vid','$message','$color','$fontsize','$mode','$playtime','$date')";
$result=mysql_query($exec,$conn);
mysql_close($conn);
?>





這時讀取介面的

header('Content-Type: text/xml;');
$id=$_GET['id'];
$link=mysql_connect("localhost","root","root");
mysql_select_db("ultrax", $link);
$q="SELECT * FROM `tm_comment` WHERE playerID =$id";
mysql_query("SET NAMES utf8");
$rs = mysql_query($q, $link);
if(!$rs){die("Valid result!");}
echo "\n";
echo "\n";
while($row = mysql_fetch_row($rs))
echo "$row[5]$row[1]$row[6]\n";
echo "";
mysql_free_result($rs);
?>


現在有個問題,我的介面

能寫進資料

但是就是讀取不了(資料庫IP,使用者名稱,密碼,資料庫的庫名我都沒寫錯)


------解決方案--------------------
$id=$_GET['id'];
這裡不可能擷取id的 因為你的資料庫根本就不存在id這個列
------解決方案--------------------
$q="SELECT * FROM `tm_comment` WHERE playerID ='$id'";

因為 `playerID` text NOT NULL,
------解決方案--------------------
正解。。。 id怎麼設成text? 用INT吧。。
探討

$q="SELECT * FROM `tm_comment` WHERE playerID ='$id'";

因為 `playerID` text NOT NULL,

------解決方案--------------------
暈倒!才探索資料類型出錯了!~~~
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.