好吧,我tryna使這個代碼執行每個電話號碼在我的分貝。在遵循這裏的建議之前,我一次只能發送一個數字,我得到了一些建議來添加一段時間的數據來循環它。但是,我的代碼不想再工作。這是之前和之後。我知道我做錯了什麼。使用while語句執行一個數組
BEFORE(工作,沒有DB)
// Set SMS options
$data['post'] = array (
'_rnr_se' => $rnrse,
'phoneNumber' => '123456789',
'text' => 'This is a test SMS',
'id' => ''
);
// Send the SMS
$response = xcurl::fetch('api.gateway.com/', $data);
// Evaluate the response
$value = json_decode($response['data']);
if($value->ok) {
echo "SMS message sent! ({$data['post']['phoneNumber']}: {$data['post']['text']})";
} else {
echo "Unable to send SMS! Error Code ({$value->data->code})\n\n";
echo 'data: '; print_r( $data); echo "\n\n";
echo 'response: '; print_r($response);
}
後(使用DB不工作)
// Set SMS options
mysql_connect("localhost", "music", "") or
die("Could not connect: " . mysql_error()); mysql_select_db("music");
$result = mysql_query("SELECT id, numbers FROM account_templates");
while ($row = mysql_fetch_array($result)) {
$data['post'] = array (
'_rnr_se' => $rnrse,
'phoneNumber' => $row['numbers'],
'text' => 'This is a test SMS',
'id' => ''
);
// Send the SMS
$response = xcurl::fetch('api.gateway.com', $data);
// Evaluate the response
$value = json_decode($response['data']);
}
if($value->ok) {
echo "SMS message sent! ({$data['post']['phoneNumber']}: {$data['post']['text']})";
} else {
echo "Unable to send SMS! Error Code ({$value->data->code})\n\n";
echo 'data: '; print_r( $data); echo "\n\n";
echo 'response: '; print_r($response);
}
可能重複的[運行陣列多發性倍](http://stackoverflow.com/questions/3130598/run-陣列多次) – 2010-06-28 08:09:57
其實不是它的一個不同的問題,同樣的腳本 – Aaron 2010-06-28 08:11:46
試圖修復它最好的我可以,希望有人能幫助我! – Aaron 2010-06-28 08:27:30