简体   繁体   English

如何使用在另一个php页面的一个html页面中定义的用户输入从Oracle数据库中获取数据

[英]how to use a user input defined in one html page in another php page to fetch data from oracle database

I have one php page which connects to the oracle database and fetches some data based on some user input. 我有一个php页面,它连接到oracle数据库并根据一些用户输入获取一些数据。 Here in this case Once the user will enter the user_id, and submit it, my code will fetch some more data (REQUEST_TIME,WORKFLOW_NAME,EVENT_MESSAGE) of that user. 在这种情况下,一旦用户输入user_id并提交,我的代码将获取该用户的更多数据(REQUEST_TIME,WORKFLOW_NAME,EVENT_MESSAGE)。 I am running below code and i am not sure if i am doing it correct. 我正在运行下面的代码,并且我不确定自己是否执行正确。 I am getting below error: 我得到以下错误:

Warning: oci_execute(): ORA-00904: "USER_ID": invalid identifier in D:\\SVN\\TOOLBOX_WEB\\WEBContent\\admin\\V2\\public\\ssn\\index2.php on line 36 警告:oci_execute():ORA-00904:“ USER_ID”:第36行的D:\\ SVN \\ TOOLBOX_WEB \\ WEBContent \\ admin \\ V2 \\ public \\ ssn \\ index2.php中的标识符无效

can someone please guide, how to proceed. 有人可以指导,如何进行。

This is my php page: 这是我的php页面:

<pre><?php

include('mypage.php');
class logAgent
{
    const CONFIG_FILENAME = "data_config.ini";

    private $_dbConn;
    private $_config;

    function __construct()
    {
        $this->_loadConfig();


        $this->_dbConn = oci_connect($this->_config['db_usrnm'],
            $this->_config['db_pwd'],
            $this->_config['hostnm_sid']);
    }
    private function _loadConfig()
    {
        // Loads config
        $path = dirname(__FILE__) . '/' . self::CONFIG_FILENAME;
        $this->_config = parse_ini_file($path) ;
    }
    public function fetchLogs() {
        $uid =$_POST["USER_ID"];

        $sql = "SELECT REQUEST_TIME,WORKFLOW_NAME,EVENT_MESSAGE
                            FROM AUTH_LOGS WHERE USER_ID = '".$uid."'";

        //Preparing an Oracle statement for execution
        $statement = oci_parse($this->_dbConn, $sql);

        //Executing statement
        oci_execute($statement);
        while (($row = oci_fetch_row($statement)) != false) {
            foreach ($row as $item) {
                echo $item . " ";
            }
            echo "\n";
        }
    }
}
?>

mypage.php mypage.php

 <!DOCTYPE html> <html> <head> <title>User_Logs</title> </head> <body> <?php if ($_SERVER["REQUEST_METHOD"] == "POST"){ $uid =$_POST["USER_ID"]; $logAgent = new logAgent(); $logAgent->fetchLogs(); } ?> <form method="POST" id="form-add" action="index2.php"> USER_ID: <input type="text" name="USER_ID"/><br> <input type="submit" name="submit" value="Get_Logs"/> </form> </body> </html> 

According to your error, oracle is complaining that it can't find the field USER_ID. 根据您的错误,oracle在抱怨找不到USER_ID字段。 Looking at your SELECT statement in the php file, oracle expects that field to be in your AUTH_LOGS table. 查看php文件中的SELECT语句,oracle希望该字段位于您的AUTH_LOGS表中。 Check to ensure that you've spelt the name of the field correctly or that the field exists in the table. 检查以确保您正确拼写了字段名称,或者该字段存在于表中。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用锚标记将信息从一个页面发送到另一个页面,并从php中的数据库中获取数据 - how to send information form one page to another page using anchor tag and fetch data from database in php 如何将用户输入数据发送到PHP以及如何将数据从一个PHP页面发送到另一个PHP页面 - How would I send user input data to PHP & send data from one PHP page to another PHP page 如何使用Ajax从一个HTML页面中使用数据来检索要在另一HTML页面上使用的数据 - How to use data from one HTML page to retrieve data to be used on another HTML page using ajax PHP - 如何将用户输入日期从一个表单(页面)传递到另一个填写相同信息以供用户验证 - PHP - How pass user input date from one form (page) to another filling in the same info for the user to verify 如何在 Laravel 中将用户定义的数据从一个页面发送到另一个页面 - How can I send a user defined data from one page to another in Laravel 7 我们可以使用同一页面中另一种形式的用户输入数据吗 - can we use user input data from one form in another form of same page Html 如何将数据从一页发送到另一页 - Html how send data from one page to another page 如何从一个页面获取JavaScript并在另一页面的php中使用它 - How to take javascript from one page and use it in php on another page 如何从PHP页面上的数据库表中获取数据 - How to fetch data from database table on PHP page 将html数据从一个php页面发送到另一个 - Send html data from one php page to another
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM