代码
ad.php$pt_ad_num='16';$pt_ad_name['1']='头部右侧文字链';
$pt_ad_size['1']='728*15全站';$pt_ad_name['2']='头部右侧banner两列';
$pt_ad_size['2']='728*60';......
处理页面include ad.php;
if ($_GET['action']=='edit'){
$id=$_GET['id'];
$file = '../inc/js/'.$id.'.js';
$adcode = @fread(@fopen($file,'r'),@filesize($file));
$adcode = str_replace('document.writeln("','',$adcode);
$adcode = str_replace('");','',$adcode);
$adcode = str_replace('")','',$adcode);
$adcode = str_replace('\\\\','\\',$adcode);
$adcode = str_replace("\'","'",$adcode);
$adcode = str_replace('\"','"',$adcode);
$adcode = str_replace('\/','/',$adcode);
?>
<form method="POST" action="?action=save&id=<?=$id?>">
<table width="99%" border="0" align="center" cellpadding="3" cellspacing="1" class="table">
<tr>
<td height="40" colspan="4" class="center_title"><div align="center" >广告修改(广告编号-<?=$id?>)
</div></td>
</tr>
<tr>
<td class="right_title" width=30%><strong> 广告名称:</strong></td>
<td class="left_txt"><input name="pt_ad_name" type="text" value="<? echo $pt_ad_name[$id];?>" size="30" ><font color="#000000"> 广告的名称,便于区分</font></td>
</tr>
<tr>
<td class="right_title"><strong> 广告大小:</strong></td>
<td class="left_txt"><input name="pt_ad_size" type="text" value="<? echo $pt_ad_size[$id];?>" size="30" ><font color="#000000"> 广告所在位置的大小</font></td>
</tr>
<tr>
<td class="right_title"><strong> 广告代码:</strong></td>
<td class="left_txt" ><textarea style="width:580px; height:220px;" name="pt_ad_code"><?=$adcode;?></textarea></td>
</tr>
<tr>
<td class="right_title"> 使用说明</td>
<td class="left_txt" style="line-height:25px"><font color=red>1、注意:所有广告都不要超高、超宽,否则将造成页面错位。<br></font>
2、调用代码为<?=$pt_ad_code[广告编号]?>,复制后到合适的广告位粘贴即可。<br>
3、非js调用,不用转换,在代码框直接修改即可</td></tr>
<tr>
<td class="forumrow" height="40" colspan="4" align="center">
<input name="cmdSave" type="submit" class="input" value="确认修改" >
</td>
</tr>
</table>
</form><?
}elseif ($_GET['action']=="save"){
$pt_ad_name[$id]=$_POST['pt_ad_name'];
$pt_ad_size[$id]=$_POST['pt_ad_size'];
echo $pt_ad_name[$id];
}
?>修改完值点了确认修改后获得的$pt_ad_name[$id]只有第一个字符
而直接输出$_POST['pt_ad_name']是正确的
貌似是$pt_ad_name[1] 这个数组只能获取原来值的第一个字符了 这个是怎么回事?
ad.php$pt_ad_num='16';$pt_ad_name['1']='头部右侧文字链';
$pt_ad_size['1']='728*15全站';$pt_ad_name['2']='头部右侧banner两列';
$pt_ad_size['2']='728*60';......
处理页面include ad.php;
if ($_GET['action']=='edit'){
$id=$_GET['id'];
$file = '../inc/js/'.$id.'.js';
$adcode = @fread(@fopen($file,'r'),@filesize($file));
$adcode = str_replace('document.writeln("','',$adcode);
$adcode = str_replace('");','',$adcode);
$adcode = str_replace('")','',$adcode);
$adcode = str_replace('\\\\','\\',$adcode);
$adcode = str_replace("\'","'",$adcode);
$adcode = str_replace('\"','"',$adcode);
$adcode = str_replace('\/','/',$adcode);
?>
<form method="POST" action="?action=save&id=<?=$id?>">
<table width="99%" border="0" align="center" cellpadding="3" cellspacing="1" class="table">
<tr>
<td height="40" colspan="4" class="center_title"><div align="center" >广告修改(广告编号-<?=$id?>)
</div></td>
</tr>
<tr>
<td class="right_title" width=30%><strong> 广告名称:</strong></td>
<td class="left_txt"><input name="pt_ad_name" type="text" value="<? echo $pt_ad_name[$id];?>" size="30" ><font color="#000000"> 广告的名称,便于区分</font></td>
</tr>
<tr>
<td class="right_title"><strong> 广告大小:</strong></td>
<td class="left_txt"><input name="pt_ad_size" type="text" value="<? echo $pt_ad_size[$id];?>" size="30" ><font color="#000000"> 广告所在位置的大小</font></td>
</tr>
<tr>
<td class="right_title"><strong> 广告代码:</strong></td>
<td class="left_txt" ><textarea style="width:580px; height:220px;" name="pt_ad_code"><?=$adcode;?></textarea></td>
</tr>
<tr>
<td class="right_title"> 使用说明</td>
<td class="left_txt" style="line-height:25px"><font color=red>1、注意:所有广告都不要超高、超宽,否则将造成页面错位。<br></font>
2、调用代码为<?=$pt_ad_code[广告编号]?>,复制后到合适的广告位粘贴即可。<br>
3、非js调用,不用转换,在代码框直接修改即可</td></tr>
<tr>
<td class="forumrow" height="40" colspan="4" align="center">
<input name="cmdSave" type="submit" class="input" value="确认修改" >
</td>
</tr>
</table>
</form><?
}elseif ($_GET['action']=="save"){
$pt_ad_name[$id]=$_POST['pt_ad_name'];
$pt_ad_size[$id]=$_POST['pt_ad_size'];
echo $pt_ad_name[$id];
}
?>修改完值点了确认修改后获得的$pt_ad_name[$id]只有第一个字符
而直接输出$_POST['pt_ad_name']是正确的
貌似是$pt_ad_name[1] 这个数组只能获取原来值的第一个字符了 这个是怎么回事?
echo $ptadname[$id];你就明白怎么回事了。。
这样是可以
但是我想把修改的值写入ad.php文件
而直接在save这个里面输出ad.php文件的任意一个数组变量都是只有一个字符
两边的变量名不一样就可以了。。
print_r($pt_ad_name);
print_r($pt_ad_size);
看一下 什么情况如果正常 再把这段代码往下面贴
直接输出$_POST['pt_ad_name']是正确的
貌似是$pt_ad_name[1] 这个数组只能获取原来值的第一个字符了 这个是怎么回事?
这是因为你的 $pt_ad_name 已经赋值为字符串了
那么提交后 $_POST['pt_ad_name'] 将伴随一个 $pt_ad_name你自己看一下就知道了