PHP未声明变量错误

PHP未声明变量错误,php,Php,我的代码和表格: <?php include("includes/connect.php"); $content = "SELECT * FROM content where content_page='home'"; $result = mysql_query($content); $row = mysql_fetch_array($result); ?> <form method="post" action="admin_home.php"> Headline:<

我的代码和表格:

<?php
include("includes/connect.php");
$content = "SELECT * FROM content where content_page='home'";
$result = mysql_query($content);
$row = mysql_fetch_array($result);
?>
<form method="post" action="admin_home.php">
Headline:</br>
<input type="text" name="content_title" value="<?php echo "$row[content_title]" ?>"></br>   </br>
Main content:</br>
<textarea type="text" class="txtinput" cols="55" rows="20" name="content_text"><?php echo   "$row[content_text]" ?></textarea></br></br>
<input type="submit" name="submit" value="Save changes">
</form>
第63行是我的提交按钮代码的下一行:

SET content_title='$content_title', content_text='$content_text' WHERE 

这不是在声明它们吗?

看起来您正在查找表单的
POST

它们不包含在变量
$content\u title
$content\u text
中。事实上,您的错误告诉您没有为这些变量分配任何内容

它们包含在
$\u POST
数组中,就像submit的值一样


这些变量不存在。你怎么会对这个错误感到惊讶?@johncode厌倦了打字会让程序员变得马虎;-)逃跑不见了!在将变量中的任何内容添加到SQL字符串之前,请阅读有关SQL注入的内容,并添加对
mysql\u real\u escape\u string()的调用。
!非常正确。解决了您的问题@Sven。
Notice: Undefined variable: content_title in /Applications/XAMPP/xamppfiles/htdocs/templacreations/admin/admin_home.php on line 63

Notice: Undefined variable: content_text in /Applications/XAMPP/xamppfiles/htdocs/templacreations/admin/admin_home.php on line 63
SET content_title='$content_title', content_text='$content_text' WHERE 
<?php 

include("includes/connect.php");
if(isset($_POST['submit'])){ 
  //Sanitize data and assign value to variable 
  $content_title = mysql_real_escape_string($_POST['content_title']); 
  $content_text = mysql_real_escape_string($_POST['content_text']);

  $order = "UPDATE content 
            SET content_title='$content_title', content_text='$content_text' 
            WHERE content_page='home'";
  mysql_query($order);

}

?>