gpt4 book ai didi

php - 添加到脚本 echo file_get_contents(myfile.php) 后,脚本 myfile.php 的某些部分将不起作用。知道为什么吗?

转载 作者:行者123 更新时间:2023-11-30 00:47:39 27 4
gpt4 key购买 nike

echo "<tr><td colspan='5' id='row1-info' class='emarNote'>
<div id='odgovor'>

<form name='form' action='insertodg.php' method='post' onsubmit='return validateForm()' class='odgovor-form frame inbtn rlarge'>
<input type='text' name='odgovor' placeholder='Odgovorite...' class='odgovor-input'/>
<input type='hidden' name='id' value='$id' />
<input name='submitodgovor' type='submit' value='Go' class='odgovor-btn' />
</form>

</div>
</td></tr>";
}
echo "</table>";

该脚本现在可以正常工作,但是当我将整个表单排除在外,并使用 file_get_contents() 调用时,它会给我一个错误 - 像 myfieldId 之类的东西不能为空,并且不是。我真的不知道那是什么?

所以如果我这样做,

echo "<tr><td colspan='5' id='row1-info' class='emarNote'>
echo file_get_contents ("myfile.php");
echo "</td></tr>";

第一个错误是第 26 行 C:\wamp\www\insertfile.php 中的未定义索引:用户。此代码来自insertfile.php

$sql="INSERT INTO answers 
SET answer = '$_POST[answer]',
user = '$_POST[user]',
questionId = (SELECT id FROM questions WHERE id = '$_POST[id]');

";

第二个错误是列 questionId 不能为空。但是,当未排除该文件时,一切正常,并且 questionId 列有一些值。

最佳答案

包含 PHP 代码来执行它的正确方法是 include construct及相关声明:

The include statement includes and evaluates the specified file.

您正在使用file_get_contents() :

Reads entire file into a string

...然后echo :

Output one or more strings

因此您不再执行 PHP 代码。您只需打印字符串。

关于php - 添加到脚本 echo file_get_contents(myfile.php) 后,脚本 myfile.php 的某些部分将不起作用。知道为什么吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21224065/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com