我有一個頁面,允許用戶使用HTML5畫布繪製圖片,使用JavaScript將其轉換爲文本併發布到PHP頁面。爲什麼PHP不能顯示我的變量?
http://dsiextensions.co.cc/chatdraw.php 該網頁是相當混亂,每個文本框是爲100px X 100像素的畫布的每一行。要將數據放入框中,請單擊「完成」,然後單擊「提交」(對不起,它確實很慢)。
我已經嘗試對PHP代碼進行更改,偶爾會顯示變量,但通常不會顯示,但不會顯示。
下面的代碼:(注意,僅在第一個框中的數據此刻正使用)
<?php
$dstring = $_POST['senddata1'];
$darray = str_split($dstring);
echo $dstring;
print_r($darray);
$x=1;
$y=1;
for ($a=0;$a<100;$a++)
{
if($a%100==0 && $a!=0){
echo '<br />'; //Checks if it is the 100th pixel and adds a new line (not needed at the moment)
$y++;
$x=1;}
//echo $x . ',' . $y . '(' . $a . ',' . $darray[$a] . ')|';
if($darray[$a]!=0){
echo "<input type='button' style='width:15;height:15;background-color:#000' />"; //Black button if it is a black pixel
}
else{
echo "<input type='button' style='width:15;height:15;background-color:#fff' />"; //White button if it is a white pixel
}
$x++;
}
?>
應該檢查像素是黑色或白色,並創建一個彩色按鈕的代碼基於(我將在後面使用圖像函數),但是$ dstring永遠不會被回顯,因此無法轉換爲數組。有沒有我在這裏做錯了或者是服務器問題?
感謝
問題是您並不總是收到senddata1值? 問題可能在客戶端而不是服務器端? – 2010-05-28 15:48:42
'var_dump($ _ POST);'?的結果是什麼? – jeroen 2010-05-28 17:47:42