pdo

Checking for empty result (php, pdo, mysql)

徘徊边缘 提交于 2020-01-18 21:38:09
问题 Please, can anyone tell me what I'm doing wrong here? I'm simply retrieving results from a table then adding them to an array. Everything works as expected until I check for an empty result... This gets the match, adds it to my array and echoes the result as expected: $today = date('Y-m-d', strtotime('now')); $sth = $db->prepare("SELECT id_email FROM db WHERE hardcopy = '1' AND hardcopy_date <= :today AND hardcopy_sent = '0' ORDER BY id_email ASC"); $sth->bindParam(':today',$today, PDO::PARAM

Checking for empty result (php, pdo, mysql)

可紊 提交于 2020-01-18 21:35:48
问题 Please, can anyone tell me what I'm doing wrong here? I'm simply retrieving results from a table then adding them to an array. Everything works as expected until I check for an empty result... This gets the match, adds it to my array and echoes the result as expected: $today = date('Y-m-d', strtotime('now')); $sth = $db->prepare("SELECT id_email FROM db WHERE hardcopy = '1' AND hardcopy_date <= :today AND hardcopy_sent = '0' ORDER BY id_email ASC"); $sth->bindParam(':today',$today, PDO::PARAM

Checking for empty result (php, pdo, mysql)

会有一股神秘感。 提交于 2020-01-18 21:35:29
问题 Please, can anyone tell me what I'm doing wrong here? I'm simply retrieving results from a table then adding them to an array. Everything works as expected until I check for an empty result... This gets the match, adds it to my array and echoes the result as expected: $today = date('Y-m-d', strtotime('now')); $sth = $db->prepare("SELECT id_email FROM db WHERE hardcopy = '1' AND hardcopy_date <= :today AND hardcopy_sent = '0' ORDER BY id_email ASC"); $sth->bindParam(':today',$today, PDO::PARAM

PHP: Convert INSERT MySQLi to PDO [duplicate]

社会主义新天地 提交于 2020-01-17 14:46:31
问题 This question already has an answer here : Changing from mysqli to pdo (1 answer) Closed last month . I'm new in PDO programming. Based on my question, can anyone help me to convert MySQLi to PDO? Below is the code: <?php require_once "config.php"; $photo_before = $_POST['photo_before']; $report_id = $_GET["report_id"] ?? ""; $sql_query = "UPDATE report SET photo_before ='$photo_before', time_photo_before = NOW(), ot_start = '16:00:00' WHERE report_id = '$report_id'"; if(mysqli_query($conn,

Android Error: Value <br of type java.lang.String cannot be converted to JSONObject

瘦欲@ 提交于 2020-01-17 14:18:20
问题 Currently, I create an apps with a login function. To connect from android to MySQL database, I use PHP. When I use MySQLi, everything is okay. But when I convert to PDO, The error will appear the same as my question's title. Can anyone knows what is the problem? Below is my PHP code: <?php require_once 'configPDO.php'; $response = array(); if(isTheseParametersAvailable(array('badgeid', 'pwd'))){ $badgeid = $_POST['badgeid']; $pwd = $_POST['pwd']; $stmt = $conn->prepare("SELECT badgeid, email

Clarity on PHP Prepared Statement Escaping

狂风中的少年 提交于 2020-01-17 10:19:37
问题 I know this is quite a popular question and, having researched for many hours now, I am still a little unsure on a definitive answer. I am no pro at PHP and have been self teaching for a little while now. I have just recently got my head around MYSQLi prepared statements (having been used to the old practice). My main question is trying to find a definitive answer on the requirement to use real escape string (or any other security) when using prepared statements. I have ready through the

Pass a variable from view to model in mvc

旧城冷巷雨未停 提交于 2020-01-17 08:15:06
问题 I am trying to build a comment system. The database structure TABLE `posts` ( `post_id` int(11) unsigned NOT NULL AUTO_INCREMENT, `post_text` text NOT NULL, `user_id` int(11) NOT NULL, `post_creation` TIMESTAMP NOT NULL ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`post_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; TABLE `comments` ( `comment_id` int(11) unsigned NOT NULL AUTO_INCREMENT, `comment_text` text NOT NULL, `comment_creation` TIMESTAMP NOT NULL ON UPDATE CURRENT

PHP connecting to IBM DB2 failed because of licensing (SQLSTATE=42968)

烈酒焚心 提交于 2020-01-17 07:48:22
问题 Good day everyone! I need to get info from stored procedures in IBM DB2 database on remote server. I've downloaded to my centOs 7.3 (with php7.1.8) drivers ibm_data_server_driver_for_odbc_cli.tar.gz and compiled ibm_db2.so and pdo_ibm.so php -m and phpinfo() shows that modules installed $db = new PDO("ibm:DRIVER={IBM DB2 ODBC DRIVER};DATABASE=testdb;" . "HOSTNAME=11.22.33.444;PORT=56789;PROTOCOL=TCPIP;", "testuser", "tespass"); If using wrong password - got this: "SQLSTATE=08001,

Can't connect to external database with Zend Framework but mysql_connect works

佐手、 提交于 2020-01-17 06:57:31
问题 I am trying to connect to multiple databases with Zend Framework. When I connect using the same credentials with mysql_connect, it works just fine. When I connect with Zend I get "Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[28000] [1045] Access denied for user 'xxxx'@'localhost' (using password: YES)' in C:\wamp\www\zend\library\Zend\Db\Adapter\Pdo\Abstract.php on line 144" I was following the tutorial at http://www.amazium.com/blog/using-different-databases-with

Can't connect to external database with Zend Framework but mysql_connect works

雨燕双飞 提交于 2020-01-17 06:57:21
问题 I am trying to connect to multiple databases with Zend Framework. When I connect using the same credentials with mysql_connect, it works just fine. When I connect with Zend I get "Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[28000] [1045] Access denied for user 'xxxx'@'localhost' (using password: YES)' in C:\wamp\www\zend\library\Zend\Db\Adapter\Pdo\Abstract.php on line 144" I was following the tutorial at http://www.amazium.com/blog/using-different-databases-with