2014-10-20 32 views
1

echo $ values ['sqlcolumnname'];即使vardump $值工作,也不會返回顯示值... 我試圖在屏幕上以可讀格式返回這些值。 我可能失去了一些東西簡單在這裏,但我很新的PHP ...謝謝你提前

<?php 
    mysql_connect("localhost:3306","root","admin"); 
    mysql_select_db("smlc"); 

    $result = mysql_query("SELECT * FROM `service_times`"); 
    $values = mysql_fetch_array($result); 

    echo $values ['service_times_title']; 
    echo $values ['service_times_content']; 
?> 

的var_dump的輸出是:

array(6) { [0]=> string(1) "1" ["Service_times_id"]=> string(1) "1" [1]=> string(24) "Regular Worship Services" ["Service_times_title"]=> string(24) "Regular Worship Services" [2]=> string(118) "Holy Communion: Sunday 8:30 a.m. & 11:00 a.m. Sunday School: 9:45 a.m. between services Nursery care is available." ["Service_times_content"]=> string(118) "Holy Communion: Sunday 8:30 a.m. & 11:00 a.m. Sunday School: 9:45 a.m. between services Nursery care is available." } string(118) "Holy Communion: Sunday 8:30 a.m. & 11:00 a.m. Sunday School: 9:45 a.m. between services Nursery care is available." string(24) "Regular Worship Services" 

當我用var_dump($值[ 'service_times_title']);該值返回NULL。我沒有嘗試循環它,沒有任何效果。我以爲我並不需要它循環,因爲我只需要第一行的值。

(這是不是從一個教程做了,但是我用一個以前在其他項目) 再次感謝

+1

如果只是這麼簡單。使用循環雙循環。 – 2014-10-20 21:09:14

+1

你是否按照教程?如果是的話,你有可能發佈鏈接嗎?我只是出於好奇而問,@ Fred-ii-已經提到了解決方案。 – 2014-10-20 21:12:52

+2

你可以添加var_dump的輸出嗎?否則有任何錯誤?如果你做'var_dump($ values ['service_times_title']);'? – Niko 2014-10-20 21:34:19

回答

0

謝謝尼科,通過的var_dump照看事實證明,我有我的列標題缺失帽。

相關問題