pdo

php do while won't work with next->rowset

南楼画角 提交于 2019-12-23 21:19:56
问题 Hi i have my wamp server on my computer PHP 5.4.12 Apache 2.4.4 MYSQL 5.6.12 And my server PHP 5.5.3 Apache 2.4.6 MYSQL 5.5.37 and when i'm doing this function on my server i have this error : SQLSTATE[HY000]: General error but in my localhost i don't have any error function getinformationpublic($nocate) { try { $public = array(); global $Cnn; $reponse = $Cnn->prepare("CALL GetInfoPublicCible(:nocategorie)"); $reponse->bindParam('nocategorie',$nocate,PDO::PARAM_INT); $reponse->execute(); do {

How to get first row of data in sqlite3 using php PDO

爷,独闯天下 提交于 2019-12-23 20:22:41
问题 How to get first row of data in sqlite3 using php PDO As per my below code first row data does not display becuase I have used recordset for check row is return or not. Any idea how to get all data from record set? My Code. try { $dbhandle = new PDO("sqlite:".$database); } catch (PDOException $e) { echo 'Connection failed: ' . $e->getMessage(); } $result=$dbhandle->query("select * from table"); if($result) { if($rs1==$result->fetchColumn()) { while ($rs1 = $result->fetch(PDO::FETCH_ASSOC, PDO

passing search parameter through jquery

笑着哭i 提交于 2019-12-23 20:12:40
问题 i have a form in which if the user enters the search query, its parameter should be passed through jquery and after getting the results it should load the results in the div container. since i'm not very well-versed with jquery, how would i do this? html: //currently the data is being displayed on pageload: $(document).ready(function() { $("#bquote").load("quotes_in.php") }); $(".bsearch") .keydown(function() { //pass the parameter to the php page //display in div #bquote }); <!-- Begin

php PDO::FETCH_ASSOC doesnt detect select after backup in stored procedure

寵の児 提交于 2019-12-23 19:48:13
问题 I have a stored procedure which make a backup and then return 1 or 0 if there is an error or not something like this: Create procedure [dbo].[sp_IWBackup] as begin declare @route varchar(500), @answer int = 0 set nocount on set @route = 'I:\route'+(replace((replace(convert(varchar, getdate(), 21),':',';')),'.',';'))+'Full.bak' set @answer = 1 begin try backup database databasename to disk = @route end try begin catch set @answer = 0 end catch select @answer as answer end In sql it works and

How to get more information from PDO failure “Error!: SQLSTATE[HY093]: Invalid parameter number: parameter was not defined”?

风流意气都作罢 提交于 2019-12-23 18:03:54
问题 Every once in a while I get an error such as the following with PDO: Error!: SQLSTATE[HY093]: Invalid parameter number: parameter was not defined Is there any way to get a more specific error, such as a line number, filename, the parameter that is missing, etc., instead of a vague message? 回答1: Firstly, ensure that you have PDO set to throw exceptions on error: $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); Now, ensure that every PDO operation/set of operations is enclosed a

binding regular expression to PDO parameter in PDO statement

非 Y 不嫁゛ 提交于 2019-12-23 17:48:20
问题 Ok, so I am fairly new to php and mysql. I am creating a php front end to mysql database. I am using PDO driver to access the database, since it prevents sql injection attacks. So far it has been fine until I came to this problem. I have a search function where a user can type company name full or partial to search for data about it. Here is PDO statement I am using to carry out the search in database: SELECT CompName FROM CompanyName WHERE CompName REGEXP :name ORDER BY CompName ASC LIMIT 1

Connection Error - SQLSTATE[HY000] [2002] Operation timed out

安稳与你 提交于 2019-12-23 17:17:04
问题 I am having trouble connecting from my application server which is a Windows 2008 R2 box to MySQL Server box also running on Windows 2008 R2. The Laravel application reports the error: exception 'PDOException' with message 'SQLSTATE[HY000] [2002] Operation timed out' The odd thing is I can connect via MySQL Workbench from the application server to the MySQL Server using exactly the same credentials and port, and the connection is quick. Can anyone shed any light on how this can be? 回答1: Check

How do I install PDO drivers for PHP on Windows?

不问归期 提交于 2019-12-23 17:12:20
问题 I installed Apache, PHP 5.6 and MySQL 5.7 on a Windows server. In php.ini, I enabled the following: extension=php_mysql.dll extension=php_mysqli.dll extension=php_oci8_12c.dll extension=php_pdo_mysql.dll extension=php_pdo_oci.dll (And restarted Apache) But when I try to use PDO in my php page, it still throws the error: Fatal error: Uncaught exception 'PDOException' with message 'could not find driver' What do I have to do to get PDO installed? 回答1: The problem was the extension_dir directive

PDO error: General error: 2031 [duplicate]

穿精又带淫゛_ 提交于 2019-12-23 17:03:53
问题 This question already has answers here : PDO error: SQLSTATE[HY000]: General error: 2031 (7 answers) Closed 5 years ago . I get this error when i'm executing my code. I know this has been discussed a several times here but i couldn't solve my problem by reading the solutions provided there. This is the error i get: Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error: 2031 This is my code: function insertMarker(){ $lat = $_POST['lat']; $long = $_POST[

PHP, PDO, and Exceptions

南楼画角 提交于 2019-12-23 16:49:00
问题 I'm currently in a bit of a dilemma regarding PDO. I've recently switched to using it from my own custom database class as I want to take advantage of transactions. The problem I'm facing is how to throw exceptions from inside a block of code that is already wrapped with try/catch for PDO. Here is an example... try { // PDO code // Transaction start // Throw manual exception here if error occurs (transaction rollback too) // Transaction commit } catch (PDOException $e) { // Transaction