Currently, I am in the process of converting my Mysqli code to PDO for an Ajax infinite scroll system that I came across on the internet. My goal is to integrate this into the blog project I am working on to enhance my understanding of PHP. if( isset($_PO ...
I'm currently facing an issue with updating my database using PDO. While I can easily select data without any problems, the update function just doesn't seem to work. There are no error messages displayed, but after running the query, there are no changes ...
I am completely new to utilizing php and pdos. A close associate of mine has actually put together a pdo class along with a few examples detailing how it can be employed, and so far, everything has been running smoothly for me. However, I have encountered ...
Currently exploring PHP and enhancing my skills. <?php // Establishing a connection with the database $dbhost = "localhost"; $dbname = "pdo"; $dbuser = "root"; $dbpass = "7777777"; $conn = new PDO("mysql:host=$dbhost;dbname=$dbn ...
The issue There is a significant delay in the execution of AJAX requests that involve any database queries. This problem has suddenly emerged without any recent updates to the codebase. Interestingly, if the same query is executed on a webpage directly (e ...
I am currently working on retrieving currency ids from a database using the following code: $arr = []; $currency_codes = array("USD", "RUB"); $currency_codes_in = implode(',', array_fill(0, count($currency_codes), '?')); $query = "SELECT `curr_id` FROM ` ...
It seems that using PDO Prepared Statements protects against SQL injection and ' escapes. I recently tested the following code... if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST["id"])) { $id = $_POST["id"]; //$id = "2&ap ...
I'm attempting to search two columns in a database with this small PDO statement: $search = $pdo->prepare(" SELECT * FROM books WHERE MATCH (title, author) AGAINST (? IN BOOLEAN MODE); "); $search->execute(array('*' . $_POST['search'] . '*')); ...
I'm encountering an issue with SQL in Laravel within a controller. Below is my code snippet: public function getKeyword() { $date = strftime("%Y-%m-%d"); echo ($date); $keyword = DB::table('demo_question_keyword') ...
After starting to use PDO, I noticed that even though when I bind param I can define the type of value being sent, my queries always seem to work fine when sending them as strings via execute. So, I'm trying to understand the purpose (which exists, I just ...
I am facing a similar question to the one discussed here. From what I gathered from that discussion, it seems that PDO::lastInsertId() is secure when called from different connections. However, does this imply that using PDO::ATTR_PERSISTENT => true in ...
After making the switch from using mysql_ functions to PDO, I've encountered a bit of a challenge that I'm hoping to get some help with. The issue I'm facing is with the search query. Currently, I have it set up like this: $result = $DB->prepare('SELE ...
After reading through various threads on this issue, I still haven't found a solution that incorporates php variables. I am trying to retrieve the first 100 new records after a specific date from my database, but I'm struggling to make it work. ...
I'm currently attempting to create an object-oriented programming (OOP) login system using Ajax. However, I am encountering issues with starting the session or being redirected to the "Directivo.php" page. When I run the code, there is no output displayed. ...
Currently, our main database connection is using mysqli. However, we are considering transitioning to Doctrine DBAL, which is built on top of PDO, a more flexible database abstraction layer. The game plan is to gradually shift from mysqli to DBAL while re ...
Having an issue with my web interface design for a database where values from a query are getting duplicated because 2 indices are counting the same value. Any ideas on why this might be happening? Here is the PHP code snippet: function loadTable() { ...
I'm struggling with a form that writes data to a MySQL database. My goal is to allow users to download their submitted data in CSV format once they complete the form. Currently, my code is displaying the database contents on the browser instead of ge ...
As I work on developing an Ajax chat application, I have found the need to periodically call a PHP script that checks for new messages in the database. I recently learned about PDO prepared statements and thought they could be useful since only one variab ...
I'm currently working on a script that calculates page load time using functions. I am particularly interested in utilizing PDO for inserting data into a database. Homepage <?php require 'common.php'; require 'page_load_statistics.php'; page_load_sta ...
I've been searching for an answer to this question, but unfortunately no one has been able to solve my problem. My query is about increasing a database field value. Here's the issue: when I refresh the page for the first time, it automatically ad ...
Looking to develop a PHP search engine that can filter search results by time, like Google's refine search feature. The twist is using a select dropdown instead of a submit button. Using SQL Server as the database with pdo-sqlsrv driver. Regular searc ...
Struggling with using AJAX to send values over to a PHP file for updating a MySQL database on the server. However, I've encountered an issue where the values don't seem to be properly transferred to the PHP file. This is the JavaScript code I am currently ...
UPDATE: Tried modifying the Jquery code to dynamically recreate rows, but it still doesn't work Reorganized my table structure with no success I have a PHP script that encodes my database table into an array. When I echo the json_encode, everything ...
I've encountered an issue with inserting data into a MySQL database using PDO. Despite not receiving any errors, the table remains empty whenever I try to check if a row has been successfully inserted. Although I can connect to the database and perf ...
After encountering random crashes with socket errors while using the abandoned herrera-io/silex-pdo PDO provider in my Silex project, I switched to csanquer/pdo-service-provider. Everything worked perfectly on my localhost server, but upon deployment to a ...
$database_config = array( 'hostname' => 'mysql:host=myhostname;dbname=test;', 'username' => 'root', 'password' => '', 'database' => 'test', 'dbdriver' => 'pdo' ); Error Message: PDO::__construct(): php_network_getaddress ...
A mechanism has been created to enable users to determine the order in which products are displayed within a product group. This mechanism relies on a database table named "grouplines" (MySQL) with columns for group_id, product_id, and manual_order. The fi ...
Having trouble sending a JSON array from a function. This is my code: function categoryTree($parent_id = 0, $sub_mark = ''){ global $connection; $query = 'SELECT * FROM ws_categories WHERE parent_id = :parent_id ORDER BY sort_order ASC, name ASC' ...
Here is the situation: I am trying to create a system that updates a value (by adding 1 to the current value) stored in a database for a specific user who logs into the website. Below is the code I have been using: $value = $row["value"]; $add_value = $db ...
I am attempting to retrieve the status of all users from my website. Here is my table https://i.stack.imgur.com/2I3xi.png When another user adds me, their username is added to user1. If I add another user, my username gets added into user1 and theirs into ...
I'm attempting to input data into a mysql database. This data often includes German umlauts. This is the method I am using: function insertMenu($content, $date) { $session = $_SESSION['aid']; global $pdo; $pdo->exec('SET CHARACTER SET utf8 ...
I've exhausted countless methods to troubleshoot this issue, but nothing seems to be effective. How can I resolve it? I've attempted the following steps: -setting auto increment for table. -reinstalling php laravel, re-installing and verifying all PHP conf ...
Having some difficulty incorporating a where clause into a COUNT query. The following code successfully retrieves the total count of the table: $search = $_POST['search_text']; SELECT COUNT(*) FROM stories') ->fetchColumn(); However, when attempti ...
Utilizing prepared queries and binding variables to placeholders has been effective for inserting data without issues. However, a concern arose when the registration form received a value like St. John's in a field. The data was successfully written, ...
Database Structure: Table: posts Columns: postid, postsubject, contents Table: tags Columns: tagid, tagtxt Table: posts_tags Columns: postid, tagid //I have already added the posts and retrieved the last id which is stored in $newId Insert into tags t ...
I am working on an application that extracts hotel names and addresses from various websites. My challenge is inserting this data in batches of 10 into a MySQL database. If any insert fails (for example, if the hotel name exceeds 100 characters while the ...
I have been attempting to create a multiple files uploader with sorter connected to a database on my website. However, whenever I try to upload some files, the uploader sends me several notices. Notice: Undefined index: media in /var/www/mediasorter/mediau ...
I have developed a PHP service that retrieves JSON data from a table consisting of 2100 rows. My development setup includes: Xampp with Apache and MySQL Windows 10 PHP-7.0.8 I am using PDO in PHP to execute the query. The service used to function flawl ...
After spending the last hour researching, I still haven't found a straightforward solution that doesn't involve complicated exports and imports. All I want to do is establish a PDO connection with two databases so that I can utilize them both in ...
Having recently started working with PHP, I've encountered a challenge with creating a dynamic HTML table. I managed to get the table functioning correctly and successfully inserted values into a MySQL database. However, I'm struggling to underst ...
Having some difficulty with this code lately. Everything is running smoothly except for the Tax query, which seems to be causing issues due to multiple TUID and UID values that are not mapping correctly (e.g., ID 1 could represent either User1 or Group1). ...
This task is quite challenging for me. I've prepared the following "insert into" statement for Postgres using PHP PDO. $sql = "INSERT INTO mytable (zuordnung_id,spielgen_id,spielvor_id) VALUES ( :zuordnung_id, ...
While using Codeigniter, I encounter an issue where it only displays "loaded" after the execution, but the table remains empty when attempting to run it with PDO: function loadCSVtoDB($csvfile){ $stmt = $this->db->conn_id->prepare("LOAD DATA ...
After executing a query to the database with LIMIT 10, I'm not getting any results. It seems like there might be an issue with my code. Can anyone spot the mistake? Here's the code snippet that I believe is causing this unexpected behavior. I'd appreciate ...
When using PDO to communicate with a MySQL database and utilizing named placeholders, it is essential to have an understanding of the database structure: $db->("INSERT INTO table (firstname, lastname, age) value (:fn, :ln, :age)"); Is there a method f ...
Is it achievable to include a custom key value pair to the existing SQL result? <?php require_once "dbaccess.php"; $json = array(); $access = new DatabaseAccess(); $sql = $access->Connect(); $stmt = $sql->prepare("select * f ...
Having issues with this code snippet: $query = "SELECT * FROM blog"; $posts = $pdo->query($query); $resultaat = $posts->rowCount(); $row = $resultaat->fetch_(PDO::FETCH_ASSOC); if($resultaat > 0){ while ($row){ echo $row['titel']; ...
Currently, I'm utilizing fetchAll(PDO::FETCH_ASSOC) to query my self-made database using an SQL statement. In order to visualize the retrieved data, I am employing print_r(). The values returned by print_r() look like this: Array ( [0] => Array ( [Type ...
This is a "wrapper" class that utilizes PDO (although it is quite extensive, the important segment is highlighted here) class DB { protected $pdo; protected $dsn; protected $username; protected $password; protec ...
While there is a lot of information available on sanitizing, filtering, and validating forms for simple inputs like email addresses, phone numbers, and addresses, the security of your application ultimately relies on its weakest link. What if your form inc ...
My current PHP code is designed to retrieve data from two different tables in MySQL using the UNION statement. $sql=" SELECT 'ticket_updates' as rowTable, sequence, ticket_seq, notes as displaydata, date ...
Recently, I upgraded to CodeIgniter 2.2.0 and decided to implement a PDO database connection with the PDO driver. However, I encountered an error that is causing some troubles for me. Can someone help me identify what might be missing in my setup? $active ...
I am working with a family tree that includes dropdown menus containing the names of parents and children. Each child has a link, and when I click on a child's link, I want their father to be displayed in the dropdown menu as the selected option. Can ...
Could someone please take a look at this code and help me find the issue? (I have already tested the database connection and it seems to be working fine). <?php $user_name=$_POST['user_name']; $password=$_POST['password']; $dbh=new ...
So here's the issue - all other PDO queries are working fine, but this one is giving me trouble. I've tried using execute(array(':t'=>$table)); but no luck. Any ideas? public function __construct($table){ try{ $pdocnx = new PDO("mysql:ho ...
I am currently utilizing ajax to fetch data from a table stored in a MySQL database. The ajax calls are being made using jQuery, with the databases being accessed through PDOs. PHP function fetchQuestions() { $database = "answerMe"; // n ...
What is the method to verify if a column's value is null? Here is an example code snippet: $db = DBCxn::getCxn(); $sql = "SELECT exercise_id, author_id, submission, result, submission_time, total_rating_votes, total_rating_values FROM submissions LEFT ...
How can I pass a PHP variable from the URL using $_REQUEST to JavaScript in order to send it through Ajax? Here is the code snippet at the top of my page: <?php include_once('../php/connection.php'); include_once('../php/getDiagnosis.php'); $pid ...
Having recently transitioned from MySQL to PostgreSQL, I installed PostgreSQL on my Fedora system and set up the postgres user following the instructions on the Fedora wiki. After creating the role using the psql shell while su-ing into the postgres user, ...
This code displays LO to the browser: ... $my_pdo_connect->beginTransaction(); $stream = $my_pdo_connect->pgsqlLOBOpen($oid, 'r'); fpassthru($stream); ... I am facing a challenge in writing the LO to the file system. While I am familiar with pg_lo_ ...
I'm seeking assistance to resolve an issue in my project. I am working on implementing a book reservation feature, and everything seems fine except for the Object-Oriented Programming (OOP) functions that involve PDO statements. Specifically, I'm facing di ...
I am currently working on setting up an array that contains all the necessary parameters for my PDO queries in a separate file. The initial query I am focusing on is a SELECT query that only requires one parameter. $data = array( 'us_id' =&g ...
Encountering the error mentioned above consistently. The issue arises with my setup depicted below: $InsertSQL = "insert into reports.NonVarassetInvoices(State, CLLI, Type, Vendor, DateReceived, InvoiceNumber, InvoiceDate, TotalInvoiceAmount, ProjectWONum ...
Recently, I discovered an interesting Firefox addon called 'SQL Inject Me'. To satisfy my curiosity, I decided to test it on a simple phonebook intranet site that has an admin account. The test results showed 51 #302 errors, but despite trying them out, I ...
Extracting and organizing username (child) and referral (parent) records from the database are done using the following code: $sql = "SELECT username, referral FROM acc_status"; $q = $conn->prepare($sql); $q->execute(array()); ...
On my HTML page, I have a form that allows users to insert data into the database. Some fields in the form require dropdown lists, and I want to populate these dropdowns with data from the database. Previously, I had hardcoded the dropdown options like th ...
I have a situation where I need to compare data between two SQL tables - one containing manually inserted data and the other with data automatically inserted by a script. To ensure that the script is functioning correctly, I want to verify that both table ...
I have implemented the following PDO SQL Query: $stmt = $pdo_conn->prepare("INSERT into ticket_updates (ticket_seq, notes, datetime, updatedby, customer, internal_message) values (:ticket_seq, :notes, :datetime, :updatedby, :customer, :internal_message ...
I have broken down my PHP files into smaller parts, for example, tillbody.php contains everything from the HTML tag to the body tag, followed by navbar.php and so on. I am including these files in index.php. Here is the code for a better understanding: &l ...
I am looking to transmit data from 3 tables in my MySQL database using JSON The tables I need to access are: $stmt1 = $db->prepare("SELECT * FROM data WHERE id='1'"); $stmt1->execute(); $result1 = $stmt1->fetch(PDO::FETCH_ASSOC); $stm ...
Whenever I try to connect to a MySQL database on localhost using PHP, I encounter a PDOException stating that the driver could not be found. $this->conn = new PDO("mysql:host=" . $this->host . ";dbname=" . $this->db_name, $this->username, $thi ...
Is there a way to assign ownership of a note in the 'notes' table to a user from the 'users' table? For example, how can I make user with id "1" in the 'users' table the owner of the note with id "2" in the 'notes' ...
Encountering a "Fatal error: Invalid handle returned. in" message in PHP 7 when attempting to connect with SQL Server. Tried the following options: Error connecting to MSSQL with SQLSrv and PHP 5.4.7 Unable to connect to SQL Server with PHP The code bei ...
I am currently working on building a binary tree using PHP, MySQL, and a jQuery plugin developed by Frank-Mich. Here is the progress I have made so far... DATABASE STRUCTURE CREATE TABLE IF NOT EXISTS `members` ( `id` int(11) NOT NULL AUTO_INCREMENT, ...
Recently, I delved into the world of PHP and database management about a month ago. Luckily, most of my issues were resolved through diligent Google searches. Currently, I am working on creating an admin feature that allows for the deletion of entries old ...