2010-11-30 63 views
0

我對PHP和MySQL相當陌生,並且繼續閱讀了各種地方的內容,我已經設法將這個腳本一起打印出來,不幸的是輸出結果並不完全符合我的預計,我得到很多的:在PHP中使用三個數據庫運行四個查詢

Buffer Status 2H: Notice: Undefined variable: row in /var/www/secretbit/allbuff.php on line 53 0 records. <br /> 
Buffer Status TC: Notice: Undefined variable: row in /var/www/secretbit/allbuff.php on line 54 0 records. <br /> 
Buffer Status ST: Notice: Undefined variable: row in /var/www/secretbit/allbuff.php on line 55 0 records. <br /> 
Buffer Status 3C: Notice: Undefined variable: row in /var/www/secretbit/allbuff.php on line 56 0 records <br /> 

這裏是我用來編譯這個怪物代碼:

<?php 

error_reporting(-1); 
ini_set('display_errors', true); 

$con = mysqli_connect(
    '192.168.20.10', 
    'root2', 
    'password', 
    'contaque' 
); 

$con2 = mysqli_connect(
    '192.168.20.222', 
    'root2', 
    'password', 
    'contaque' 
); 

$con3 = mysqli_connect(
    '192.168.20.8', 
    'root2', 
    'password', 
    'contaque' 
); 

$res = mysqli_query(
$con, 
    "SELECT COUNT(*) AS 'total1' FROM contaque_hopper WHERE campaign_id = 'CLOSERUK';" 
); 

$res = mysqli_query(
$con2, 
    "SELECT COUNT(*) AS 'total2' FROM contaque_hopper WHERE campaign_id = 'CLOSERTC';" 
); 

$res = mysqli_query(
$con2, 
    "SELECT COUNT(*) AS 'total3' FROM contaque_hopper WHERE campaign_id = 'CLOSERST';" 
); 

$res = mysqli_query(
$con3, 
    "SELECT COUNT(*) AS 'total4' FROM contaque_hopper WHERE campaign_id = 'CLOSER3C';" 
); 

echo 'Buffer Status 2H: ', (int)$row['total1'], ' records. <br />'; 
echo 'Buffer Status TC: ', (int)$row['total2'], ' records. <br />'; 
echo 'Buffer Status ST: ', (int)$row['total3'], ' records. <br />'; 
echo 'Buffer Status 3C: ', (int)$row['total4'], ' records. <br />'; 

?> 
+0

格式不正確。撰寫郵件時,請使用textarea頂部的相應格式按鈕。這次我會爲你做。 – stillstanding 2010-11-30 16:24:37

回答

4

那麼它看起來像$row是不確定的。我想你可能需要使用方法mysqli_fetch_assoc()來獲得查詢結果。

相關問題