PHP fwrite 错误
我被困住了。一直在努力解决这个问题。这个例子几乎与老师相同......我不明白......html是 这里。其简单的时间表设置。它不会正确写入文件。帮助?
编辑:它不会将变量写入文件。我可以让它写入文本,但不能写入变量。希望能澄清。
<?php
/* Create folder for data */
if (is_dir('schedule'))
chdir('schedule');
else
{mkdir('schedule');
chdir ('schedule');}
/* Variable Declaration */
/* Employee 1 */
$sunStart1=$_POST['sunStart1'];
$sunEnd1=$_POST['sunEnd1'];
$monStart1=$_POST['monStart1'];
$monEnd1=$_POST['monEnd1'];
$tuesStart1=$_POST['tuesStart1'];
$tuesEnd1=$_POST['tuesEnd1'];
$wedStart1=$_POST['wedStart1'];
$wedEnd1=$_POST['wedEnd1'];
$thurStart1=$_POST['thurStart1'];
$thurEnd1=$_POST['thurEnd1'];
$friStart1=$_POST['friStart1'];
$friEnd1=$_POST['friEnd1'];
$satStart1=$_POST['satStart1'];
$satEnd1=$_POST['satEnd1'];
/* Employee 2 */
$sunStart2=$_POST['sunStart2'];
$sunEnd2=$_POST['sunEnd2'];
$monStart2=$_POST['monStart2'];
$monEnd2=$_POST['monEnd2'];
$tuesStart2=$_POST['tuesStart2'];
$tuesEnd2=$_POST['tuesEnd2'];
$wedStart2=$_POST['wedStart2'];
$wedEnd2=$_POST['wedEnd2'];
$thurStart2=$_POST['thurStart2'];
$thurEnd2=$_POST['thurEnd2'];
$friStart2=$_POST['friStart2'];
$friEnd2=$_POST['friEnd2'];
$satStart2=$_POST['satStart2'];
$satEnd2=$_POST['satEnd2'];
/* Make data file */
$schedule = fopen('schedule.txt', 'w');
fwrite($schedule, "$sunStart1\n");
fwrite($schedule, "$sunEnd1 \n");
fwrite($schedule, "$monStart1 \n");
fwrite($schedule, "$monEnd1 \n");
fwrite($schedule, "$tuesStart1 \n");
fwrite($schedule, "$tuesEnd1 \n");
fwrite($schedule, "$wedStart1 \n");
fwrite($schedule, "$wedEnd1 \n");
fwrite($schedule, "$thurStart1 \n");
fwrite($schedule, "$thurEnd1 \n");
fwrite($schedule, "$friStart1 \n");
fwrite($schedule, "$friEnd1 \n");
fwrite($schedule, "$satStart1 \n");
fwrite($schedule, "$satEnd1 \n");
fwrite($schedule, "$sunStart2 \n");
fwrite($schedule, "$sunEnd2 \n");
fwrite($schedule, "$monStart2 \n");
fwrite($schedule, "$monEnd2 \n");
fwrite($schedule, "$tuesStart2 \n");
fwrite($schedule, "$tuesEnd2 \n");
fwrite($schedule, "$wedStart2 \n");
fwrite($schedule, "$wedEnd2 \n");
fwrite($schedule, "$thurStart2 \n");
fwrite($schedule, "$thurEnd2 \n");
fwrite($schedule, "$friStart2 \n");
fwrite($schedule, "$friEnd2 \n");
fwrite($schedule, "$satStart2 \n");
fwrite($schedule, "$satEnd2 \n");
fclose ($schedule);
?>
I'm stuck. Been trying to fix this. The example is almost identical to the teachers... I don't get it.... The html is here. Its simple setup for a schedule. It won't write to the file correctly. Help?
EDIT: It won't write the variables to the file. I can get it to write text, just not the variables. Hope that clarifies.
<?php
/* Create folder for data */
if (is_dir('schedule'))
chdir('schedule');
else
{mkdir('schedule');
chdir ('schedule');}
/* Variable Declaration */
/* Employee 1 */
$sunStart1=$_POST['sunStart1'];
$sunEnd1=$_POST['sunEnd1'];
$monStart1=$_POST['monStart1'];
$monEnd1=$_POST['monEnd1'];
$tuesStart1=$_POST['tuesStart1'];
$tuesEnd1=$_POST['tuesEnd1'];
$wedStart1=$_POST['wedStart1'];
$wedEnd1=$_POST['wedEnd1'];
$thurStart1=$_POST['thurStart1'];
$thurEnd1=$_POST['thurEnd1'];
$friStart1=$_POST['friStart1'];
$friEnd1=$_POST['friEnd1'];
$satStart1=$_POST['satStart1'];
$satEnd1=$_POST['satEnd1'];
/* Employee 2 */
$sunStart2=$_POST['sunStart2'];
$sunEnd2=$_POST['sunEnd2'];
$monStart2=$_POST['monStart2'];
$monEnd2=$_POST['monEnd2'];
$tuesStart2=$_POST['tuesStart2'];
$tuesEnd2=$_POST['tuesEnd2'];
$wedStart2=$_POST['wedStart2'];
$wedEnd2=$_POST['wedEnd2'];
$thurStart2=$_POST['thurStart2'];
$thurEnd2=$_POST['thurEnd2'];
$friStart2=$_POST['friStart2'];
$friEnd2=$_POST['friEnd2'];
$satStart2=$_POST['satStart2'];
$satEnd2=$_POST['satEnd2'];
/* Make data file */
$schedule = fopen('schedule.txt', 'w');
fwrite($schedule, "$sunStart1\n");
fwrite($schedule, "$sunEnd1 \n");
fwrite($schedule, "$monStart1 \n");
fwrite($schedule, "$monEnd1 \n");
fwrite($schedule, "$tuesStart1 \n");
fwrite($schedule, "$tuesEnd1 \n");
fwrite($schedule, "$wedStart1 \n");
fwrite($schedule, "$wedEnd1 \n");
fwrite($schedule, "$thurStart1 \n");
fwrite($schedule, "$thurEnd1 \n");
fwrite($schedule, "$friStart1 \n");
fwrite($schedule, "$friEnd1 \n");
fwrite($schedule, "$satStart1 \n");
fwrite($schedule, "$satEnd1 \n");
fwrite($schedule, "$sunStart2 \n");
fwrite($schedule, "$sunEnd2 \n");
fwrite($schedule, "$monStart2 \n");
fwrite($schedule, "$monEnd2 \n");
fwrite($schedule, "$tuesStart2 \n");
fwrite($schedule, "$tuesEnd2 \n");
fwrite($schedule, "$wedStart2 \n");
fwrite($schedule, "$wedEnd2 \n");
fwrite($schedule, "$thurStart2 \n");
fwrite($schedule, "$thurEnd2 \n");
fwrite($schedule, "$friStart2 \n");
fwrite($schedule, "$friEnd2 \n");
fwrite($schedule, "$satStart2 \n");
fwrite($schedule, "$satEnd2 \n");
fclose ($schedule);
?>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的表单方法语法不正确...
您
应该是
加上您的表单结构也不正确...
我会将
Your forms method is not syntaxed correctly...
You have
It should be
Plus your form structure is also not correct...
I would place the
<form>
before the<table>
and subsequenctly end</form>
after</table>