pdo

PDO::ATTR_PERSISTENT utf 8 encoding

徘徊边缘 提交于 2019-12-24 15:07:50
问题 I set PDO::ATTR_PERSISTENT => true , but show my text with other encoding! همراه سوران باشید در Please help me out // This is not helpful : `PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8',` // my default encoding in phpmyadmin is utf8-general 来源: https://stackoverflow.com/questions/29714253/pdoattr-persistent-utf-8-encoding

function bind_param() on a non-object in my new code

送分小仙女□ 提交于 2019-12-24 15:02:03
问题 I am trying to change my PHP code into another secure one so I change the update.PHP page from this to that: <?php require_once ('../include/global.php'); $id=$_REQUEST['id']; if (isset ($_POST['name'])) { $name = $_POST['name']; } if (isset ($_POST['remarcs'])) { $remarcs = $_POST['remarcs']; } if (isset ($_POST['test_res'])) { $test_res = $_POST['test_res']; } if (isset ($_POST['address'])) { $address = $_POST['address']; } if (isset ($_POST['date'])) { $date = $_POST['date']; } if (isset (

PHP: LOAD DATA INFILE syntax errors

不羁岁月 提交于 2019-12-24 14:03:45
问题 I'm trying to import csv data into mysql using PDO and LOAD DATA INFILE (I've also tried LOAD DATA LOCAL INFILE) but I keep getting a syntax error and I have no idea why. The filepath and table names seem to be correct. here is the import() function I am using - function import() { $this->db = mydb::getConnection(); // set the column names for the selected journal table if ($this->table = "bsp_journals") { $columns = "category, discipline, subject, sourcetype, issn, publicationname,

php pdo connection to mssql instance

依然范特西╮ 提交于 2019-12-24 13:58:16
问题 I'm running into a problem connecting to a MSSQL database from PHP. We've got 2 applications on the same linux-server. App A connects to a "simple" MSSQL server+database, and has no problem. App B connects to a MSSQL server + INSTANCE + database, and fails to connect. The fact that the database is within an "instance" of the MSSQL server seems to be the only difference. The documentation appears not to specify how to connect to a database within an instance. Example (pseudo) code: <?php $host

Smarty Object Function with Associative Array Unexpected “=>”, expected one of: “”,“” , “)”'

霸气de小男生 提交于 2019-12-24 13:29:45
问题 I am having a problem with Smarty passing a PDO Object to Smarty it just doesn't like => . Is there a trick to get around this problem? Here is he error: {assign var='brgdatas' value="{$brgObj->fetchOneBrg(array('id'=>{$ststres[ststval].to_id}'))}"}" - Unexpected "=>", expected one of: "","" , ") Here is the code I am working with: {section name=ststval loop=$ststres} {if $ststres[ststval].type == 2} {assign var='brgdatas' value="{$brgObj->fetchOneBrg(array('id'=>{$ststres[ststval].to_id}'))}

Setting PDO::ATTR_EMULATE_PREPARES to false not working

。_饼干妹妹 提交于 2019-12-24 13:15:25
问题 I've tried disabling emulated prepares in PDO but I cannot get it to work. Everything else works. The query is successful. The reason I believe it's not working is because it does not escape quotes and such so I get syntax errors. I've tried doing it two different ways. $this->dbh->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); and $insert = $database->$con->prepare($insert, array(PDO::ATTR_EMULATE_PREPARES => false)); I've also noticed that getAttribute does not work. By doing this...

MySQL Error 111 Can't connect to server

浪尽此生 提交于 2019-12-24 13:06:39
问题 I have a connection.php file that is suppose to connect to a remote database. Here is the code: <?php try { $conn = new PDO('mysql:host=IP;port=PORT;dbname=DBNAME', 'USERNAME', 'PASSWORD'); } catch (PDOException $e) { print "Error!: " . $e->getMessage() . "<br/>"; die(); } ?> Now all my variables I believe are correct since I can connect to the database through Toad. I used this same PDO format for my own database connection through localhost and it works fine. I am not sure what the problem

Is $_SESSION safe from sql injects?

主宰稳场 提交于 2019-12-24 12:48:23
问题 I use PDO to access my MySQL database, and want to use IN. But sadly it don't seam to work with prepare, so I wrote this function function is_numeric_array($array){ if(!is_array($array)) return is_numeric($array); if(is_array($array)) foreach($array as $int) if(!is_numeric($int)) return false; return true; } Then used it like this if(!is_numeric_array($_SESSION['story'])){ die("Error, array contains non-integers"); } $query = "("; for($i = 0; $i<count($_SESSION['story']); $i++) $query .= $

Enforce inserting records into multiple tables

前提是你 提交于 2019-12-24 12:21:15
问题 I have two tables parent and child . I would like to insert a record in both tables only if the query succeeds for both. Ideally, integrity would be enforced by the database, however, doing so using the application would be acceptable if necessary. Potentially, I could do something like the following, however, it seems like there would be a more elegant method to do so. How should this be accomplished? <?php //parent must be inserted first as child has a FK constraint to it $stmt1=$conn-

Executing prepared PDO statement gives “General error: 10 disk I/O error” (PHP)

拈花ヽ惹草 提交于 2019-12-24 12:09:06
问题 $sql = "REPLACE INTO `myTable` VALUES (:symbol1, :symbol1), (:symbol1, :symbol2)"; $statement = $this->pdoObject->prepare($sql); $statement->execute(array(':symbol1' => $symbol1, ':symbol2' => $symbol2)); The above throws a PDOException: SQLSTATE[HY000]: General error: 10 disk I/O error I don't see an error in the statement. 来源: https://stackoverflow.com/questions/33607983/executing-prepared-pdo-statement-gives-general-error-10-disk-i-o-error-php