Instance of PDO in class connector

I'm working on a project today and i've been working for a while now and i don't see what i do wrong here. Can someone give me the right example. Thnx a lot! Connector: class Repository { private $connector; public function __construct(Config $co...
more »

2017-04-18 23:04 (1) Answers

PDO returning empty result

I have the below PHP script which generates a MySQL query and runs it, however currently the query is returning an empty result. $sth = $dbh->prepare("SELECT TeamID FROM UserTeam WHERE UserID=? AND Deleted IS NULL"); $sth->execute(...
more »

2017-04-18 23:04 (3) Answers

Proper noun capitalization in MySQL

Let me set the stage. I am working with a MySQL to input customer company names, for example "My Company" using PHP/PDO. In PHP, I am aware of the ucwords(), ucfirst, strtoupper(), and strtolower() functions. Are there any good practices as to how to...
more »

2017-04-18 21:04 (0) Answers

INNER join doesn't work with PDO in PHP

I'm facing a very strange problem. I have a SQL Server query which is very simple and working fine in any environment. I ran it and it was fine, but in my PHP, code doesn't work for some reason, and it returns empty array: function conexion() { $us...
more »

2017-04-18 14:04 (1) Answers

PHP PDO Camel Case

<?php $query = "SELECT p.id as ItemId FROM production p"; $pdo -> beginTransaction(); // PDO try { $pdo->setAttribute( PDO::ATTR_CASE, PDO::CASE_NATURAL ); $result = $pdo->query($query); $test = $result->fetchAll(PDO::FETC...
more »

2017-04-18 14:04 (0) Answers

Laravel - SQLSTATE[42S22] - Foreign key

I'm trying to implements a 'has one' relation but this error prevent me to save the token. Migrations : class CreatePasswordTokensTable extends Migration { public function up() { Schema::create('password_tokens', function (Blueprin...
more »

2017-04-18 11:04 (3) Answers

Display records from multiple table in PDO mysql

Want to print Participant information like firstName, organization from two different table. Query is working properly as it is giving desired results. But when I try to print fetched data, it returns an error. function get_all_participant(){ incl...
more »

2017-04-18 09:04 (1) Answers

Stumped with PHP PDO response to a sql query

I am creating an update proogram that takes the winner and loser of a game and adds their wins, loses, points for and points against to their profle in sql db. I have successfuly written the side for the winner, but when replicating tfor the loser, i...
more »

2017-04-18 06:04 (0) Answers

Update multiples columns using PDO

How do i add multiples columns in pdo for update? this is what I am trying to do but I need to update multiple $_POSTS['VARS]; $consulta = $conexao_pdo->prepare('UPDATE user SET nome = ? WHERE id = ?'); $consulta->bindParam(1, $variavel_com_n...
more »

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

if statement for PDO duplicate error

I have to following code to move a particular row to another table. $id = $_GET['id']; $table = $_GET['name']; $trashtable = $_GET['name'] . "_trash"; $movetotable = $conn->prepare("INSERT INTO `$table` SELECT * FROM `$trashtable` WHERE id = :id...
more »

2017-04-17 21:04 (0) Answers

Can't insert data to mysql using PDO

Please tell me, what am I doing wrong. <?php if ( empty( $_POST ) ){ ?> <form name='registration' action='pdo1.php' method='POST'/> <input type="text" name="user_name"> <input type="password" name="password"> <input...
more »

2017-04-17 07:04 (3) Answers

PDO PHP Array issue

function chkQuestions($info) { $query = $this->handle->prepare("SELECT * FROM tbltest"); $query->execute(); $rows = $query->fetchAll(); $getPost = $query->rowCount(); foreach($rows as $row...
more »

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

Php - PDO Database

Below is my function to check radio button questions to the answer with the answer stored in the database. function chkQuestions($info) { $query = $this->handle->prepare("SELECT * FROM tbltest"); $query->execute(); $rows = $q...
more »

2017-04-16 19:04 (1) Answers

How to fetch varbinary column data with pdo

Hello all I have difficulty to fetch a varbinary(7680) column with pdo, i use sqlv server. This is a table containing information about player items. This is my attempt to bring result. $check_ware = $chup->prepare("Select Items from warehouse wh...
more »

2017-04-16 15:04 (0) Answers

php json encode parse error

This php file verify the id and code a user was emailed with. If the id and code match a confirmation message is shown else an error message is shown. The script is converted to json and the error returned occurs while parsing the json converted php....
more »

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

PDO connection alternatives issue

I have tried out two different types of PDO connections, both of them are working fine on localhost, but only one of them work properly on a remote server even though they both use exactly the same credentials. The first that works both on localhost...
more »

2017-04-16 12:04 (0) Answers

Insert data from Form PDO with Required Fields

Please i need help with this form i have those problems 1- When it submit write error but i see in PHPMyAdmin it's added and record in MySql Database Example: Error: INSERT INTO clients (name, email, website, comment, gender) VALUES ('', '', '', '', ...
more »

2017-04-15 20:04 (2) Answers

FETCH_ASSOC PDO Continuously Looping

I'm new to PDO and I am converting to it from MySQLi due to recent issues I've been having with my web space. I am trying to use FETCH_ASSOC to loop through results to get the individual records produced by my query, however, the loop is never endin...
more »

2017-04-15 19:04 (0) Answers

PHP PDO connection failing without error

It's been many years since I did any dev in PHP. The concept of connecting to MySQL using PDO is completely new to me, and I don't seem to be able to get it to work. Using MySQLi, and the following code, which I know is deprecated, works nicely: &l...
more »

2017-04-15 08:04 (1) Answers

PHP PDO Get expired_date

I have table password_recovery with columns: id, email, resetToken, resetComplete, date_created, date_expired When I use submit form save thus: 1, test@gmail.com, 30e7abdecd7790cebf61d2fb74bdad82, No, 14 April, 2017, 21:01, 14 April, 2017, 22:01 H...
more »

2017-04-14 22:04 (0) Answers

How to call while loop from class?

I have class getinfo.php and script welcome.php. Inside get info class I have the function GetAll. I want to call all "first" by variable $this->first and is returning only one value, but I want all "first" in the row.Please see below //script g...
more »

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

PDO binded variable from Array

I am creating an advanced search function in my project. Here a user can "check" for what criteria them want to display from my Logg table. This means that there can be various length of each array posted to my Controller. Example of an post: log...
more »

2017-04-14 14:04 (0) Answers