0
我具有與從現場從MySQL表陣列的PHP文件的問題:PHP的MySQL字符串字段轉換爲數字陣列
printf的後<?php
require "lib/config.php";
$users = array();
error_reporting(0);
$UTB = $config['dbTableNames']['users'];
mysql_connect($config['dbConnection']['host'], $config['dbConnection']['user'], $config['dbConnection']['pass']);
mysql_select_db($config['dbConnection']['name']);
$GuID = mysql_query("SELECT ID, Channels FROM $UTB");
if (mysql_affected_rows() == 1) {
while ($rGuID = mysql_fetch_array($GuID)) {
$uID = $rGuID['ID'];
$users[$uID]['channels'] = array($rGuID['Channels']);
printf($rGuID['Channels'] . ' ');
}
}
結果(只用於顯示的值)爲:
0,1 0,1 0 0,1 0,1 0,1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
如果我手動設置這個數組我AjaxChat網站工作正常(while循環之後),但我至少有40個用戶配置是這樣的:
$users[1]['channels'] = array(0, 1);
$users[2]['channels'] = array(0, 1);
$users[3]['channels'] = array(0);
...
Channels
字段類型(在MySQL表中)爲VARCHAR大小255,值爲0
或0,1
。