prepared-statement

Having trouble executing a SELECT query in a prepared statement

梦想的初衷 提交于 2020-01-09 18:34:06
问题 Ive followed a bunch of different examples regarding using a SELECT in a prepared statement, but nothing is returned. EDIT I have changed my code a bit to look like this: $date1 = 2012-01-01; $date2 = 2012-01-31; $sql_con = new mysqli('db', 'username', 'password', 'database'); if($stmt = $sql_con->prepare("SELECT eventLogID FROM Country WHERE countryCode=? AND date BETWEEN ? AND ?")){ $stmt->bind_param("sss", $country_code, $date1,$date2); $stmt->execute(); $i=0; while ($stmt->fetch()){ $stmt

Are PHP MySQLi prepared queries with bound parameters secure?

 ̄綄美尐妖づ 提交于 2020-01-09 10:51:25
问题 Historically, I've always used mysql_real_escape_string() for all input derived from users that ends up touching the database. Now that I've completely converted over to MySQLi and I'm using prepared queries with bound parameters, have I effectively eliminated the possibility of SQL injection attacks? Am I correct in saying I no longer need mysql_real_escape_string()? This is my understanding and the basis of a project of mine: http://sourceforge.net/projects/mysqldoneright/files/Base

Are PHP MySQLi prepared queries with bound parameters secure?

爱⌒轻易说出口 提交于 2020-01-09 10:50:54
问题 Historically, I've always used mysql_real_escape_string() for all input derived from users that ends up touching the database. Now that I've completely converted over to MySQLi and I'm using prepared queries with bound parameters, have I effectively eliminated the possibility of SQL injection attacks? Am I correct in saying I no longer need mysql_real_escape_string()? This is my understanding and the basis of a project of mine: http://sourceforge.net/projects/mysqldoneright/files/Base

How do I use pdo's prepared statement for order by and limit clauses?

时光总嘲笑我的痴心妄想 提交于 2020-01-08 16:35:34
问题 I want to use a prepared statement in which the passed-in parameters are for the ORDER BY and LIMIT clauses, like so: $sql = 'SELECT * FROM table ORDER BY :sort :dir LIMIT :start, :results'; $stmt = $dbh->prepare($sql); $stmt->execute(array( 'sort' => $_GET['sort'], 'dir' => $_GET['dir'], 'start' => $_GET['start'], 'results' => $_GET['results'], ) ); But $stmt->fetchAll(PDO::FETCH_ASSOC); returns nothing. Can someone point out what's the wrong thing I am doing? Can it be done? If not,what

How do I use pdo's prepared statement for order by and limit clauses?

做~自己de王妃 提交于 2020-01-08 16:35:04
问题 I want to use a prepared statement in which the passed-in parameters are for the ORDER BY and LIMIT clauses, like so: $sql = 'SELECT * FROM table ORDER BY :sort :dir LIMIT :start, :results'; $stmt = $dbh->prepare($sql); $stmt->execute(array( 'sort' => $_GET['sort'], 'dir' => $_GET['dir'], 'start' => $_GET['start'], 'results' => $_GET['results'], ) ); But $stmt->fetchAll(PDO::FETCH_ASSOC); returns nothing. Can someone point out what's the wrong thing I am doing? Can it be done? If not,what

PHP prepared statement insert from a loop of data

别说谁变了你拦得住时间么 提交于 2020-01-07 08:34:07
问题 Any ideas as to why my data isn't being updated? Is their something fundamentally wrong with how I'm writing my prepared statement? The form: while($log_dates = mysqli_fetch_assoc($q_log_dates_result)) { echo "<tr>"; echo "<input type='hidden' name='data[][log_dates_ID]' value='" . $log_dates['log_dates_ID'] . "'/>"; echo "<td><input type='text' name='data[][week_date]' value='" . $log_dates['week_date'] . "' /></td>"; echo "<td><input type='text' name='data[][crew_chief]' value='" . $log

PDO prepared Statements correct?

霸气de小男生 提交于 2020-01-07 08:24:06
问题 I am trying to use some PDO prepared statements for the first time to prevent a SQL Injection. I am quite new to SQL so the prepared statements are very bewildering to me. Do you think my SQL code with prepared statements is correct? <?php if ( $_SERVER["REQUEST_METHOD"] == 'POST' ) { $suche = htmlspecialchars($_POST['suche']); $stmt->bindParam(':suche', $suche); if (!empty($suche)) { $sql = new rex_sql; $sql->debugsql = 0; $stmt = $sql->prepare("SELECT * FROM rex_downloads WHERE dateiname

Prepared Statement: How to join header

て烟熏妆下的殇ゞ 提交于 2020-01-07 06:52:20
问题 I've got 2 tables where i want to join the header and the first column within an prepared statement. I've got managed to join the column, but how to join the header? Table1 : ID |Name ---------- 1 | A 2 | B 3 | C 4 | D 5 | E Table2 : TeamA|TeamB|Won|Lost -------------------- 1 | 2 | 5 | 3 1 | 3 | 2 | 4 1 | 4 | 9 | 1 2 | 5 | 5 | 5 3 | 1 | 2 | 4 Result-Matrix: | A | B | C | D | E ---------------------------- A | 0 | 2 | -2 | 8 | 0 B | 0 | 0 | 0 | 0 | 0 C | -2 | 0 | 0 | 0 | 0 SQL Fiddle 回答1: In

prepareStatement() appears to be stripping semicolon

为君一笑 提交于 2020-01-06 15:51:24
问题 I am trying to execute a prepared statment using the following: dbaBean.setPrepStmt(dbaBean.getConn().prepareStatement( "SELECT id, author, title, url, article_text, date_created " + "FROM articles WHERE " + "(EXTRACT(YEAR FROM date_created) = ? OR ? is null) " + "AND (EXTRACT(MONTH FROM date_created) = ? OR ? is null) " + "AND (EXTRACT(DAY FROM date_created) = ? OR ? is null) AND " + "(url = ? OR ? is null) " + "ORDER BY date_created DESC;")); dbaBean.getPrepStmt().setString(1, year);

Can Someone hello explain this class for a php threaded comments system?

蓝咒 提交于 2020-01-06 15:32:29
问题 I am trying to implement a threaded comment system using php, and i found something already written, but i can not exactly see how to use it, i am not familiar at all with classes, so i was wondering if someone could help explain how i would use the code. the code below is from the website http://www.jongales.com/blog/2009/01/27/php-class-for-threaded-comments/ the code for the classes is as follows: class Threaded_comments { public $parents = array(); public $children = array(); /** * @param