php - PHP 变量 $id =$_GET('id') 有值但不能在代码中工作
问题描述
我目前正在尝试使用 php 制作一个基本网站,在其中我基本上可以编辑博客等。当 i9 双击当前文本时,我已经创建了它,以便打开 iframe 弹出窗口以更改文本。此 iframe 的 src 为editbox.php?id=<?php echo $id ?>
($id 适用于父页面)。
问题是代码中的 $Id 似乎在 $query 部分中没有得到识别,即使它似乎具有正确的值
iframe 页面的代码如下:
<?php
include_once('../includes/connection.php');
include_once('../includes/article.php');
$article = new Article;
$id =$_GET['id'];
print_r($id);
$data = $article->fetch_data($id);
if (isset($_POST['content'])) {
$content = $_POST['content'];
$uid =$_GET['id'];
$query = $pdo->prepare("UPDATE articles SET article_content='$content' WHERE article_id='$id'");
$query->execute();?>
<script>parent.location.href=parent.location.href</script>
<?php }?>
<script>
function textAreaAdjust(element){
element.style.height = "auto"
element.style.height = (25+element.scrollHeight)+"px";
}</script>
<link rel="stylesheet" href="../Assets/style2.css" />
<form action="editbox.php" method="post" autocomplete="off">
<textarea autofocus="true" onfocus="textAreaAdjust(this);" onkeyup="textAreaAdjust(this)" cols="157" placeholder="Content" name="content" ><?php echo $data['article_content']?></textarea><br /><br />
<input type="Submit" value="Add article" />
</form>
奇怪的是 print_r 返回一个 3 这是它应该返回的,但由于某种原因它不起作用。
如果我将它从$id =$_GET('id')
to更改它也可以工作,$id=3
但由于 id 是动态的,我不能这样做。
对不起,如果上面的代码有其他问题,我是新手。
解决方案
推荐阅读
- angular - 通过单击按钮 angular 4 屏蔽和取消屏蔽输入字段值
- wxpython - wxpython双面板窗口显示信息
- java - Java Gson .add 函数不采用字符串参数(maven 项目)
- python - pyImporterror 从父文件夹运行子文件夹 python 脚本
- kubernetes - DeploymentConfig 上的 Openshift Origin 1.5.1 Pod 反关联性不起作用
- sql - 如何获取指定为年和季度的两个日期之间的差异
- react-native - React-navigation,如何从 navigatorRef 获取路线
- javascript - jsPDF 输出所有唯一的屏幕截图,而不是打印整个内容
- java - OkHttp MockWebServer 无法接受 android P (API 28) Instrumentation Test 中的连接
- teradata-sql-assistant - teradata 助手中的 SQL 插入语句