Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/57.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在mysql表字段上插入id页_Php_Mysql - Fatal编程技术网

Php 在mysql表字段上插入id页

Php 在mysql表字段上插入id页,php,mysql,Php,Mysql,如何在mysql数据库中插入当前页面的编号(ID) 我有一个疑问: $page = $_REQUEST['id']; addslashes($page); $query = "insert into files (file_id,subid,fname,fdesc,tcid,floc) values ($newstd,'$page','" . htmlspecialchars($_REQUEST['fname'], ENT_

如何在mysql数据库中插入当前页面的编号(ID)

我有一个疑问:

     $page = $_REQUEST['id'];
            addslashes($page);
             $query = "insert into files 
(file_id,subid,fname,fdesc,tcid,floc) values ($newstd,'$page','" 
    . htmlspecialchars($_REQUEST['fname'], ENT_QUOTES) . "','" 
    . htmlspecialchars($_REQUEST['fdesc'], ENT_QUOTES) 
    . "','" . $_SESSION['tcid'] . "','" 
    . htmlspecialchars($_REQUEST['floc'], ENT_QUOTES) . "')";
页面id类似于index.php?id=2

    I've tried this $page = $_GET['page'];
    addslashes($page);
    This gets the page value from the url, for example
 if you went to index.php?page=LOL it would return LOL 
into that $page variable. We now 
apply addslashes() to the $page variable
 for security reasons, as we are going to be using 
this in a MySQL query.
但它不起作用

表配置:

  CREATE TABLE IF NOT EXISTS `files` (
  `file_id` int(11) NOT NULL,
  `floc` varchar(500) NOT NULL,
  `fdesc` varchar(100) NOT NULL,
  `tcid` int(11) NOT NULL,
  `subid` text NOT NULL,
  `fname` varchar(100) NOT NULL
) ENGINE=MyISAM AUTO_INCREMENT=41 DEFAULT CHARSET=latin1;

Subid
是页码。

使用
$page=$\u请求['ID']
而不是
$page=$\u GET['page']

您可以共享您的表配置吗?您想在其中插入此页面id的列的数据类型是什么?您应该将subid数据类型从int更改为text在您使用$PAGEID的查询中,但您正在创建的变量是$pageI,它从int更改为text,并且是相同的。在int中,他显示了0,现在什么也没有了。我认为在查询中,$PAGEID应该替换为$page。