pdo

Show Additional Form Data when Result is Isolated

余生长醉 提交于 2020-01-07 06:41:11
问题 I have a form that displays the results from a survey into a webpage. At the moment, when a user clicks on the 'View Here' it takes them to the individual entry for that ID. When it is clicked I would like it to also show additional results (also part of the results from the same database). Any idea how I do this? Just to clarify, it should not show until the ID is clicked to single out that entry - otherwise it shows them all in full one after the other. <?php try { $handler = new PDO('mysql

PHP PDO issue with sanitised ORDER BY fields

馋奶兔 提交于 2020-01-07 04:17:11
问题 I have an "ajax script/handler" that returns a bunch of product categories to my jqGrid. The sql ends up looking like so: $sql = 'SELECT * FROM product_categories ORDER BY :sidx :sord LIMIT :start , :limit'; $sth = $dbh->prepare($sql); $sth->bindParam(':sidx', $sidx); $sth->bindParam(':sord', $sord); $sth->bindParam(':start', $start, PDO::PARAM_INT); $sth->bindParam(':limit', $limit, PDO::PARAM_INT); $sth->execute(); Now, I've already had an issue with '$start' because PDO apparently has an

mysql 5.1 signal an error to cause PDO exceptions

我是研究僧i 提交于 2020-01-07 03:39:13
问题 I know mysql 5.5 allows using SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'Error: ...'; to raise a user defined error. And this error will stop an INSERT operation if it was put in the BEFORE INSERT TRIGGER on some tables. And it's also convenient for PDO to catch the PDOException and output the errorinfo() i.e. MESSAGE_TEXT defined in SIGNAL SQLSTATE . However, the version of mysql on the server I rent is mysql 5.1. And I want to know how can I raise a user defined error with the features

How to use SELECT IFNULL in PDO?

半城伤御伤魂 提交于 2020-01-07 02:46:08
问题 i was looking for a way to return an error if no results were found in a MySql query, at first i declared a variable value false, and if the fetch() function is true it will set the value of that boolean to true, then i check if it is true or false, but then i searched for that in internet cause i didn't like my solution that much, so I found the function IFNULL(query, 'error message'); I tried it but I had an error, can you tell me what's wrong in my code? if(isset($_POST['tosearchfor'])) {

How to connect MSSQL from PHP 7, Plesk 12.5 installed on CentOS 7

末鹿安然 提交于 2020-01-07 00:36:31
问题 My Plesk 12.5 installed on CentOS 7 and supporting multiple php versions in same time. I have successfully installed pdo_dblib driver for php version 5.4.16. Does anybody knows how to install similar driver for php 7. I have PDO enabled on php7 and support PDO drivers mysql, odbc, pgsql, sqlite. How I can add mssql. I found this links library I need php70w-pdo_dblib but how I can installed? question on the plesk site 回答1: Thanks everybody for the help. I have resolved my problem by simply

How to connect MSSQL from PHP 7, Plesk 12.5 installed on CentOS 7

末鹿安然 提交于 2020-01-07 00:36:28
问题 My Plesk 12.5 installed on CentOS 7 and supporting multiple php versions in same time. I have successfully installed pdo_dblib driver for php version 5.4.16. Does anybody knows how to install similar driver for php 7. I have PDO enabled on php7 and support PDO drivers mysql, odbc, pgsql, sqlite. How I can add mssql. I found this links library I need php70w-pdo_dblib but how I can installed? question on the plesk site 回答1: Thanks everybody for the help. I have resolved my problem by simply

No data is written into Excel

走远了吗. 提交于 2020-01-06 23:45:08
问题 I have the following code: require 'PHPExcel.php'; require 'PHPExcel/Writer/Excel2007.php'; require 'PHPExcel/IOFactory.php'; $user = "root"; $pass = "admin"; $host = "localhost"; $db = "hrtms"; $objPHPExcel = new PHPExcel(); try{ $con = new PDO("mysql:host=$host;dbname=$db",$user,$pass); $con->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION); $con->exec('SET NAMES "utf8"'); } catch(PDOException $e){ echo $e->getMessage(); exit(); } try{ $query = $con->prepare("SELECT * FROM emptb WHERE

php中的MVC

我与影子孤独终老i 提交于 2020-01-06 20:50:41
MVC模式 便于管理代码 M (model模型)音乐列表新闻列表 V (views视图) C (Controller控制器)核心连接数据库 M<=C=>V C<=V 双引号和单引号的区别 双引号里的东西输入的时候能判断是否包含变量,如果包含 变量 就一起输出 单引号不判断是否有变量,就全部当成 字符串 输出 $db = array( 'dsn' => 'mysql:host=localhost;dbname=website;port=3306;charset=utf8', 'username' => 'root', 'password' => '', ); $options = array( //默认是PDO::ERRMODE_SILENT, 0, (忽略错误模式) PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, // 默认是PDO::FETCH_BOTH, 4 PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, ); try { $this->pdo = new PDO($db['dsn'], $db['username'], $db['password'], $options); } catch (PDOException $e) { die('数据库连接失败:' . $e-

PHP installation configure: error: Cannot find php_pdo_driver.h

喜欢而已 提交于 2020-01-06 19:38:31
问题 So I have already installed Apache2 and Mysql on Linux Mint (the same as Ubuntu), Now I am trying to install PHP on Apache but I get a very strange error message : configure: error: Cannot find php_pdo_driver.h. I did some search on the Internet and I found out that these files were not embedded before in PHP, but they are now. I even checked for it myself in the PHP source folders and I found that specific file. Can anyone tell me what's the problem and how to solve it ? 回答1: actually PDO is

Can't Insert Data into Database using PDO

孤街浪徒 提交于 2020-01-06 15:29:09
问题 After sanitizing and validation, which works fine. I tried inserting data into my database but it keeps saying error: "Sorry, we were not able to sign you up... Refill the form properly" $qry = "INSERT INTO users (email, firstName, surname, userName, password, userDOB) values (?, ?, ?, ?, ?, ?)"; $q = $conn->prepare($qry) or die("ERROR: " . implode(":", $conn->errorInfo())); $q->bindParam(1, $email); $q->bindParam(2, $name); $q->bindParam(3, $surname); $q->bindParam(4, $username); $q-