2014-03-06 98 views
0

這是我第一個基於PHP的web項目。我的網絡部分工作完美,但我在移動版本遇到問題。 (在godaddy linux上的虛擬主機)我是否必須在移動設備上使用不同的PHP?

我的.php頁面不顯示的原因是什麼?如果我將其更改爲.html,它工作正常。 (我懷疑的文檔類型,但不知道。) 不知道這個代碼是必要的,但我會離開了身體空間的緣故:

<?php include_once 'web/config.php'?> 
<!DOCTYPE HTML> 
<html> 
<?xml version="1.0" encoding="UTF-8"?> 
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" 
"http://www.wapforum.org/DTD/xhtml-mobile10.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<title>About - Mobile</title> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> 
<meta name="keywords" content="About - Mobile" /> 
<link href="css/style.css" rel="stylesheet" type="text/css" media="all" /> 
</head> 

的config.php:

$link = mysqli_connect($server, $db_user, $db_pass); 
mysqli_select_db($link, $database); 

// -=-=-=-=-=-=-=[ Getting Variables ]=-=-=-=-=-=-=- // 
$query = "SELECT * FROM `misc`"; 
$result = $link->query($query); 
while($info = mysqli_fetch_array($result)){ 
// -=-=-=-=-=-=-=[ Variables ]=-=-=-=-=-=-=- // 
$pickupTime = $info['pickupTime']; 
$deliveryTime = $info['deliveryTime']; 
$minDeliveryPrice = $info['minDeliveryPrice']; 
$Gtitle = $info['Gtitle']; 
$emailAccount = $info['emailAccount']; 
$phone = $info['phone']; 
$mailSubject= $info['mailSubject']; 
$address = $info['address']; 
$city = $info['city']; 
$zipcode = $info['zipcode']; 
$companyTel = $info['companyTel']; 
$companyEmail = $info["companyEmail"]; 
$facebookLink = $info['facebookLink']; 
$twitterLink = $info['twitterLink']; 
$googleLink = $info['googleLink']; 
$termsOfService = $info['termsOfService']; 
} 
?> 

在此先感謝!

+4

這對你來說真的看起來像有效的HTML嗎? –

+3

php無法關心您使用的是什麼設備。 PHP的工作是(一般)生成HTML。您需要爲用戶的設備生成適當的html。 –

+0

您是在手機本身上運行此文本,還是您網站的移動版本?除非你有一臺服務器,否則PHP將無法工作;它是服務器端。 –

回答

3

PHP在服務器端執行,只要PHP腳本呈現有效的HTML(但這似乎不是這種情況),手機不會在意。

如果瀏覽器接收到PHP代碼,服務器出現問題(例如,您沒有在服務器端安裝PHP,或者Web服務器不知道何時調用PHP來生成網頁)

瀏覽器從不接收PHP代碼(否則,由於PHP代碼具有某種原因密碼,因此劫持數據庫會很容易)。

+0

好的,那麼頁面根本不顯示的原因是什麼?如果我將其更改爲.html,則加載完美。有任何想法嗎?謝謝! – jackdishman

+0

剛剛修改了答案,你確定是否安裝了Apache或其他可以處理PHP代碼的網絡服務器應用程序? –

+0

是的,我有它的桌面版本的PHP工作,所以它應該與此工作,對不對? – jackdishman

1

PHP在服務器上執行,客戶端不知道它正在與PHP通話。定位移動平臺時,您無需更改PHP代碼。

您的問題似乎已損壞HTML

<?php include_once 'web/config.php'?> 

我們也許應該看到config.php文件,看看有什麼是發生在那裏。

<!DOCTYPE HTML> 
<html> 

在此處打開<HTML>標記。

<?xml version="1.0" encoding="UTF-8"?> 
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" 
"http://www.wapforum.org/DTD/xhtml-mobile10.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 

在這裏,你打開另一<HTML>標籤,這是一個問題。您應該只有一個<HTML>標記作爲文檔中的外部節點。

<head> 
<title>About - Mobile</title> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> 
<meta name="keywords" content="About - Mobile" /> 
<link href="css/style.css" rel="stylesheet" type="text/css" media="all" /> 
</head> 

您不關閉<HTML>標記,並且您沒有要呈現的正文。

1

好吧,因爲你說你只發布頭。我只是要修復你的HTML至少使其有效。而對於PHP,其他的答案解釋爲什麼這條線的PHP <?php include_once 'web/config.php'?>的是輸出一些東西,是搞亂PHP不會在瀏覽器中

<?php include_once 'web/config.php'?> 
<!DOCTYPE HTML> 
<html> 
    <head> 
     <title>About - Mobile</title> 
     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
     <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> 
     <meta name="keywords" content="About - Mobile" /> 
     <link href="css/style.css" rel="stylesheet" type="text/css" media="all" /> 
    </head> 
    <body> 
    .... 
    </body> 
</html> 

如果這不起作用,那麼我猜瀏覽網站時重要html或換句話說,使它無效,所以請嘗試刪除它,然後嘗試

也是什麼意思,它不顯示?像什麼都沒有出現?或者它給(HTTP和/或PHP)錯誤?

+0

它是空白的。如果我將php取出並將擴展名更改爲.html,那麼頁面加載正常,但只要將其改爲.php,頁面即使在取出所有php時也是空白的。有任何想法嗎?謝謝! @Krimson – jackdishman

+0

@ jdish123你能告訴我你的'config.php'文件中有什麼? – Krimson

+0

將其添加到問題中。謝謝! – jackdishman

相關問題