我有Xcode 4.6。 我想連接mysql數據庫與我的應用程序。 所以我發現這個教程Xcode連接錯誤
http://www.youtube.com/watch?v=ipppykYUzh4#at=104,http://www.youtube.com/watch?v=tvv1KlZ-594
我是繼續循序漸進,但我不知道哪裏是我的錯誤。
這是我的xcode項目。請看看這個,告訴我什麼是錯的。 https://www.dropbox.com/s/4pj1xj4f736l42m/mysql.zip
感謝您的幫助。
這是PHP代碼
<?php
header('Content-type: application/json');
$DB_HostName = '127.0.0.1';
$DB_Name = 'test';
$DB_User = 'root';
$DB_Pass = '';
$con = mysql_connect($DB_HostName,$DB_User,$DB_Pass) or die(mysql_error());
mysql_select_db($DB_Name,$con) or die(mysql_error());
$sql = 'SELECT * FROM phpmysql';
$result = mysql_query($sql,$con) or die(mysql_error());
$num = mysql_numrows($result);
mysql_close();
$rows =array();
while ($r = mysql_fetch_assoc($result)){
$rows[] = $r;
}
echo json_encode($rows);
?>
THIS IS MY錯誤
2013-07-30 10:27:22.335 mysql[4095:c07] *** Assertion failure in -[UITableView dequeueReusableCellWithIdentifier:forIndexPath:], /SourceCache/UIKit_Sim/UIKit-2380.17/UITableView.m:4460
2013-07-30 10:27:22.336 mysql[4095:c07] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'unable to dequeue a cell with identifier Cell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard'
*** First throw call stack:
(0x1c91012 0x10cee7e 0x1c90e78 0xb64665 0xc46c4 0x2c88 0xcd8fb 0xcd9cf 0xb61bb 0xc6b4b 0x632dd 0x10e26b0 0x228dfc0 0x228233c 0x228deaf 0x1022bd 0x4ab56 0x4966f 0x49589 0x487e4 0x4861e 0x493d9 0x4c2d2 0xf699c 0x43574 0x4376f 0x43905 0x4c917 0x1096c 0x1194b 0x22cb5 0x23beb 0x15698 0x1becdf9 0x1becad0 0x1c06bf5 0x1c06962 0x1c37bb6 0x1c36f44 0x1c36e1b 0x1117a 0x12ffc 0x243d 0x2365)
libc++abi.dylib: terminate called throwing an exception
(lldb)
你確定你的服務器返回JSON嗎?你可以發佈堆棧跟蹤嗎? –
我的php腳本將varchar編碼爲JSON。 –