我的GET变量存在问题 [英] There is a issue with my GET variable

查看:79
本文介绍了我的GET变量存在问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当我点击编辑时,它会显示以下错误







注意:未定义的变量:_Get在第9行的C:\ xampp \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ fetch_array()在第13行的C:\ xampp \htdocs \ OOP1 \ blog \ adminmin \ editit_post.php中的非对象上



我尝试了什么:



Whenever I click edit it shows these errors below



Notice: Undefined variable: _Get in C:\xampp\htdocs\OOP1\blog\admin\edit_post.php on line 9

Fatal error: Call to a member function fetch_array() on a non-object in C:\xampp\htdocs\OOP1\blog\admin\edit_post.php on line 13

What I have tried:

          <?php 
include "../libs/config.php";
include "../libs/db.php";
 

//Creating database object
$db = new database();
//getting the id
$id = $_Get['id'];

$query = "SELECT * FROM posts WHERE id = '$id'";
$posts = $db ->select($query);
$single = $posts ->fetch_array();

//Inserting Posts
if(isset($_POST['submit'])){
  //creating variables for texts
  $title = $_POST['title'];
  $content = $_POST['content'];
  $cat = $_POST['cat'];
  $author = $_POST['author'];
  $tags = $_POST['tags'];
  //creating varibles for image
  $image = $_FILES['image']['name'];
  $image_tmp = $_FILES['image']['tmp_image'];
  

move_uploaded_file($image_tmp,"../images/$image");
  $query = "INSERT INTO posts (category_id,title,content,author,image,tags) VALUES ('$cat','$title','$content','$auhor','$image','$tags')";
 $run = $db->insert($query);
}

?>
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" href="../../../../favicon.ico">

    <title>Admin Panel</title>

    <!-- Bootstrap core CSS -->
    <link href="../styles/bootstrap.css" rel="stylesheet">

    <!-- Custom styles for this template -->
    <link href="../styles/custom.css" rel="stylesheet">
  </head>

  <body>

    <div class="blog-masthead">
      <div class="container">
        <nav class="nav">
          <a class="nav-link active" href="index.php">Dashboard</a>
          <a class="nav-link" href="add_post.php">Add New Post</a>
          <a class="nav-link" href="add_category.php">Add New Category</a>
          <a class="nav-link pull-right" href="../index.php">View Blog</a>
          <a class="nav-link pull-right" href="logout.php">Logout</a>
        </nav>
      </div>
    </div>

    <div class="blog-header">
      <div class="container">
        <h1 class="blog-title"></h1>
        <p class="lead blog-description"></p>
      </div>
    </div>

    <div class="container">

      <div class="row">

        <div class="col-sm-12 blog-main">
        <br/>
              <form action="add_post.php" method="post" enctype="multipart/form-data">
  <div class="form-group">
    <label>Post title:</label>
    <input type="text" name = "title" class="form-control"  placeholder="Enter a title" value="<?php echo $single['title'];?>"/>
    
  </div>
  <div class="form-group">
  <label>Post Content:</label>
   <textarea class="form-control" rows="3" name="content" placeholder = "Enter a content"></textarea>
   </div>
   <select name="cat" class="form-control">
    <option>Select a Category</option>
    <?php while ($row1 = $cats->fetch_array()) :?> 
    <option value="<?php echo $row['id'];?>"><?php echo $row1['title'];?></option>
 

 <?php endwhile ;?>
 </select>
  <div class="form-group">
    <label>Author Name:</label>
    <input type="text" name="author" class="form-control"  placeholder="Enter author name">
  </div>
  <div class="form-group">
 <label>Post Image:</label>
 <input type="file" name="image">
 </div> 
  <div class="form-group">
    <label>Tags:</label>
    <input type="text" name="tags" class="form-control"  placeholder="Enter text">
  </div>
  <button type="submit" name="submit" class="btn btn-success">Submit</button>
  <a href="index.php" class="btn btn-danger">Cancel</a>

</form>
          </div><!-- /.blog-main -->

          <?php include "includes/footer.php";

          ?>

推荐答案

db = new database();
// 获取ID
db = new database(); //getting the id


id =
id =


_Get [' ID ];

_Get['id'];


这篇关于我的GET变量存在问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆