PDO: Different results with SQLite BETWEEN

I have a SQLite table with dates in unix timestamp format, which I query via PHP PDO. I'd like to mark the rows according to a date range, in my case whether the date falls in the winter semester or the summer semester of the year. The start and end...
more »

2017-03-19 19:03 (1) Answers

sql join takes a long time to load

Hello fellow programmers. I have an issue with load times when using a join in my SQL query. The two tables that are being joined have roughly 5000 rows each. Any way I can cut the load time on this? Any help would be greatly appreciated! SELECT app...
more »

2017-03-19 19:03 (1) Answers

Is this solution enough to block SQL Injections

I made my simple PHP search script, but I'm not sure if this solution is enough to avoid sql injections. The only input I have there is search query input. The thing is, when someone submits my form, javascript have to push % character to the beginn...
more »

2017-03-19 13:03 (2) Answers

Error inserting records in Mysql table

I am having errors inserting records into the "shipping_order" table. Nothing is inserted and no error is returned. $randomNumber = $order_id = null; $randomNumber = mt_rand(100, 1000); $order_id = $user_id.$randomNumber; $insert = "INSERT INTO sh...
more »

2017-03-19 09:03 (0) Answers

PHP doesn't enter into database

I'm making a cart database and I want to transfer carts that have been "alive" for 48 hours into an inactive_carts table. now I have this code, but the problem is, it doesnt put it in the database, i checked and all of the $time items go in the if c...
more »

2017-03-18 17:03 (2) Answers

SQL database value to variable

So, I am kinda new to php and mysql, but I have found a login form and adapted it to my needs as I dont have the knowledge to make one my self yet. I added a firstname and surname column into the database and the register form adds the values into th...
more »

2017-03-18 03:03 (2) Answers

Extra column returned in PDO query

I'm using PDO to inner join three tables: "Users", "Teams" and the intermediary table "teams_users". "teams_users" handles the many to many relationship between Users and Teams. Many Users can be on a team. Each Team can have many users. The idea...
more »

2017-03-17 20:03 (1) Answers

Call to a member function on null?

I have done all sorts of things to understand what is actually wrong with the code, but I just couldn't figure out what was causing this error. Below is class called Topic : class Topic { // Init DB variables private $db; ...
more »

2017-03-17 18:03 (1) Answers

Use PDO and forget about data sanitizing

I am a little bit confused with using PDO and techniques of sanitizing data. If I use prepared statements with PDO in php, shall I need to use other data sanitizing techniques to protect against SQL injection? Any support is appreciated.. ...
more »

2017-03-17 16:03 (0) Answers

Display Users' Notifications PHP

I have a system where users needs to be notified of happenings in on their notification dashboard. I have been able to accomplish the notification part. My challenges are. 1. only 1 notification shows instead of all available notification. Despite us...
more »

2017-03-17 06:03 (0) Answers

How to convert mysqli code to PDO stmt?

if($_REQUEST['action'] == 'addToCart' && !empty($_REQUEST['id'])){ $productID = $_REQUEST['id']; // get product details $query = $db->query("SELECT * FROM products WHERE id = ".$productID); $row = $query-&g...
more »

2017-03-17 04:03 (1) Answers

PHP : could not find driver (PDO, MySql)

<?php error_reporting( E_ALL & ~E_DEPRECATED & ~E_NOTICE ); ob_start(); session_start(); define('DB_DRIVER', 'mysql'); define('DB_SERVER', 'localhost'); define('DB_SERVER_USERNAME', 'root'); define('DB_SERVER_PASSWORD', ''); define('DB_D...
more »

2017-03-17 03:03 (1) Answers

php: looking for php sqlsrv connection

good day i have this mysql connection structure and i wonder i somebody can help me to make a structure like sqlsrv_connection buenos dias, tengo esta conexion de php con mysql y queria saber si alguno me podria ayudar en uno parecido para sqlsrv, e...
more »

2017-03-16 17:03 (0) Answers

uploading multiple photos to specific location

I've been trying to create something that will upload multiple photos to a specific location and change it's name, tried to loop through files but something is not working and I quite can't figure out what that is! So please take a look and tell me w...
more »

2017-03-16 15:03 (1) Answers

How to write unit tests throwing PDOException

I have a class which handles a variety of database exceptions such as deadlocks and serialized transaction failures. I'm trying to unit test it and ran into a roadblock. An example of the code I want to test: public function run(callable $callable...
more »

2017-03-16 14:03 (1) Answers

Add an array in PHP into mysql

How to add a PHP array in a mysql table? try { // set the PDO error mode to exception $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // Prepare the statement so that it gets repeated $sql = $conn->prepare("INSE...
more »

2017-03-16 14:03 (2) Answers

PDO multiple select issue

I am inserting a form multiple select value in my database but it only inserts the last selected value. How can I solve this here is my code. Can someone tell me what is wrong with the code and why it is only inserting last value. Thanks PHP: ...
more »

2017-03-16 13:03 (1) Answers

How to put an array to DB (php, pdo)?

Need your help. Got some problems with putting an array's data to DB via php pdo. I'm amateur frond-end dev. that's quite far from backend, so there are no people except you to help me! In the DB table I've got some columns, among others "myActions" ...
more »

2017-03-16 11:03 (1) Answers

How to query database from a OOP point-of-view

Hey Guys I know Stackoverflow is may not the right place to ask, if there's another Stackexchange group where this question fits better, then please tell me. So, I'm trying to learn OOP. I think I understand it quite good, but there's one thing I r...
more »

2017-03-16 11:03 (2) Answers

How to use the PDO connection work in the class

I am using class to do all the database related stuff. Inside a config file contains a class that has a 'Connect' function to establish connection to the database. I have created a connection file which contains information to connect to database. No...
more »

2017-03-16 07:03 (1) Answers

Issue with PDO binding/executing

Hi here's my code I created the 2 sqlite table sample and login_info properly though this error still pops up Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 25 bind or column index out of range in C:\xampp\htdocs\display.ph...
more »

2017-03-16 03:03 (1) Answers

PDO Works for all but not in Cron Yii2

I am working on Yii2 advanced app and I have created cron job for my need but same code inside cron works in application but not works in console cron controller. It gives error like 'Class PDO not found'. namespace console\controllers; use yii\co...
more »

2017-03-16 03:03 (1) Answers