prepared-statement

mysqli_fetch_array(), prepared statement, and LIKE statement

家住魔仙堡 提交于 2019-12-25 02:56:02
问题 I'm trying to use mysqli prepared statements with a LIKE statement query and wildcard operators. After debugging be sprinkling echo statements throughout the code, I can see that my while statement is not executing. Can you see what I'm doing wrong here? This is my first time asking on this forum, so I apologize if this isn't a good question; I've spent 6 hours trying to get the prepared statement section of my code to work and I can't find any threads addressing my question that don't go

Using STR_TO_DATE in Java to INSERT Date, with PreparedStatement

空扰寡人 提交于 2019-12-25 02:24:07
问题 Let's suppose we have a JFrame called FrmRegistration . Its function is inserting data into a table called records . MySQL's command desc records would result the following: +-----------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-----------+--------------+------+-----+---------+-------+ | id | varchar(7) | NO | PRI | | | | name | varchar(100) | NO | | NULL | | | birthday | date | NO | | NULL | | +-----------+--------------+------+-----+---

Php-MySql Security approach while INSERT’ing INTO MySql & fetching from MySql to screen

我的梦境 提交于 2019-12-25 01:51:07
问题 My Approach while INSERT’ing INTO MySql I think I read in stackoverflow.com that “if you need escaping or similar action, do it just in time you need” so in the verification pages that I verify the user inputs (null or not check, length check and structural checks (eg: mail structure, custom tags structures); I use the $_POST[''] variables as inputs. During verifications, even in the custom error printing parts, my error messages does not include any of $_POST[''] values in message texts. As

Call to a member function bind_param() on a non-object

风格不统一 提交于 2019-12-24 23:15:58
问题 I know there is a ton of other questions like this, but none that I found answered my problem. I get the following error Call to a member function bind_param() on a non-object with the following code: $servername = "localhost"; $username = "MyUsername"; $password = "MyPassword"; $dbname = "MyDatabase"; $conn = new mysqli($servername, $username, $password, $dbname); var_dump($conn); $stmt = $conn->prepare("SELECT COUNT(email) FROM subscribers WHERE email LIKE ?"); var_dump($stmt); $stmt->bind

MySQLi: prepared statement to return nested arrays

邮差的信 提交于 2019-12-24 19:03:47
问题 I use this class method to return a nested/ multi-dimensional array, public function fetch_all_stmt($sql,$types = null,$params = null) { # create a prepared statement $stmt = parent::prepare($sql); if($stmt) { if($types&&$params) { $bind_names[] = $types; for ($i=0; $i<count($params);$i++) { $bind_name = 'bind' . $i; $$bind_name = $params[$i]; $bind_names[] = &$$bind_name; } $return = call_user_func_array(array($stmt,'bind_param'),$bind_names); } # execute query $stmt->execute(); # these

Why do I get “ORA-00932: inconsistent datatypes: expected - got -” when using COLLECT() in a prepared statement?

百般思念 提交于 2019-12-24 16:57:18
问题 I am using this query with the Perl DBI: SELECT c.change_id , COLLECT(t.tag) AS the_tags FROM changes c LEFT JOIN tags t ON c.change_id = t.change_id WHERE c.project = ? GROUP BY c.change_id The DBI uses OCI to prepare this statement, bind the value I pass, and get the results. But Oracle, for some reason, does not like it. The error output is: ORA-00932: inconsistent datatypes: expected - got - (DBD ERROR: error possibly near <*> indicator at char 41 in ' SELECT c.change_id , <*>COLLECT(t

Is it possible to change query after binding a parameter in mysql?

拜拜、爱过 提交于 2019-12-24 13:26:08
问题 For example: if I have this query: SELECT * FROM table WHERE test = ? then I bind a parameter, can I now add something to my query? If this is possible please give me an example in PHP. 回答1: No it isn't possible. What do you need? 回答2: No, it's not possible. You'll have to prepare a new query. 来源: https://stackoverflow.com/questions/31892748/is-it-possible-to-change-query-after-binding-a-parameter-in-mysql

jpa namedquery with literals changed to prepared statement

大城市里の小女人 提交于 2019-12-24 13:15:15
问题 I have a jpa (openjpa-2.2.1) namedquery that has some hardcoded literals (ex: a.status <> 'X') - the problem is at runtime the generated query is actually a prepared statement (a.status <> ?) Is there a way to force JPA run the query as is? (i would like to keep it as namedquery, not implement it as native query or other ways) I would like to run the query as is because of performance reasons - the static query runs in a db client in about 2 seconds while the prepared statement fired from

Why am i getting a syntax error with this prepared statement?

纵饮孤独 提交于 2019-12-24 10:58:51
问题 I am trying to learn how to do a PreparedStatement as follows: createConnection(); conn.setAutoCommit(false); String sql = "SELECT MAX(?) FROM ?"; PreparedStatement stmt = conn.prepareStatement(sql); However, when I hit the last line, it throws a java.sql.SQLSyntaxErrorException as follows: java.sql.SQLSyntaxErrorException: Syntax error: Encountered "?" at line 1, column 20. I have searched everywhere but cant find any reason for it to fail. What am I doing wrong? later on in the code I am

How to SELECT * with multiple WHERE using fetch_assoc in prepared statements in PHP-MYSQL?

徘徊边缘 提交于 2019-12-24 10:23:09
问题 It's been two days and I have not found any solution for this on Google, so please help. I have to SELECT * from one row with multiple WHERE clauses, using a prepared statements, I want to retrieve the results using fetch_assoc so that I don't have to bind variables using bind_result() , using fetch_assoc I can print many columns as $row['column_name'] . My code is below and it's not running, giving no error. $query = 'SELECT * FROM `table_name` WHERE `uid` = ? AND `email` = ?'; if ($stmt