Questions tagged [mysqli]

The mysqli PHP extension stands apart as a dedicated database driver for PHP, distinct from the MySQL database system.

Utilize PHP's bind_param function to incorporate SQL statements into your code

Currently, I'm exploring the use of SQL command preparation in order to prevent any risk of injection. However, I am facing difficulty in understanding how to incorporate SQL statements within the bind_param function. The code snippet I am working wit ...

Utilize JavaScript to extract and exhibit various SQL records stored within a multidimensional array

How can I use JS, JQuery, PHP, and MySQLi to automatically generate an HTML table within a div on a webpage? The table should display data based on user-input search criteria. For example, the user enters a start date and end date, clicks a button, which t ...

The PHP/MySQLi registration form is displaying a blank white page without any visible output or error messages

Hey everyone, I'm currently working on a simple registration form in PHP and no matter how many times I try to run it, all I get is a blank white page. There are no errors or outputs, just pure emptiness. I was hoping someone could shed some light on ...

Unable to retrieve the ID value for the HTML form

Need help updating a table in the database with individual update buttons for each row. The issue is that when the button is clicked, nothing happens because I'm struggling to pass the ID value to the form and then to an UPDATE query. while(list($na ...

The importance of managing session data

Here is my issue: I want only one session to run at a time. Consider the following query: $get_crs_mysqli .= (!empty($_SESSION['userSearch']))?(" AND (course_title like '%".$_SESSION['userSearch']."%') OR (course_title like '%" . $_SESSION['userCategory'] ...

Having trouble with the mysqli_query function, it's not working as expected. Can someone offer assistance?

Could use some help with my mysqli_query. It's not inserting into the database, even though it works in phpmyadmin SQL but not on the website. Here is my code: <form action="" method="POST> <input type="email" name="email" placeholder="P ...

The program encountered a critical issue: Trying to call a function that does not exist, mysqli

My database query is causing an issue, resulting in the error message below: Fatal error: Call to undefined function mysqli_master_query() in /home/**/**/**/edit/add.php on line 4 Take a look at my PHP code snippet: <?php $db = mysqli_connect("lo ...

What is the correct approach in utilizing AngularJS $http.post for PHP to update a MySQLi table?

I need assistance with updating a MySQLi table called "achievements" using PHP in an AngularJS app. The app calculates various statistics, and when a goal is achieved, I send the relevant information to a PHP script using AngularJS's "$http.post" method. M ...

Transforming the MySQL result array into JSON format

I am looking to transform the array result retrieved from my database query into JSON format using PHP. Below is the code snippet I am currently working with: $row = mysql_fetch_array($result) My goal is to convert the variable $row into JSON format and t ...

Ensuring the protection of an HTML form prior to transmitting data to a MySQL database

Is there a more effective way to enhance security for a public form? I am looking to maximize the security measures in place. <?php ob_start(); $sub_firstname = trim($_POST["firstname"]); $sub_lastname = trim($_POST["lastname"]); $sub_email = trim($_ ...

Why is MySQLi not retrieving all the rows?

I am seeking assistance with the following issue: SELECT s.`uid` FROM `sessions` s (I had initially included a LEFT JOIN in the query, but removed it for debugging purposes) For reference, here is the full query: SELECT s.`uid`, u.`username`, u.`email` ...

SQL injection for storing hidden dates

When I submit a value using my form, I want the date to be saved in the MySQL database. The user does not need to see it, but I need the dates for a future function where I can loop through the registered dates in the database. Do I need to create a hidde ...

Struggling to make json_encode function properly with input from database

Despite my efforts, I can't seem to get json_encode working properly for results retrieved from the fr column in my database. You can find an export of my table at mctrivia.com/language.zip. I have already switched everything to utf8mb4 as recommend ...

What is the process for including a variable in a MySQLi statement?

My current challenge involves inserting data into a MYSQLi database. When I use the query below, data gets successfully inserted: INSERT INTO table (Name, Phone, Location) VALUES ('test', 'test', 'test') However, instead of using the static value 'test', ...

Exploring ways to compare data from two different tables in separate databases using the mysqli extension in PHP

How can I compare data after connecting to different MySQL databases using mysqli? Database name garden_fruit1, password 123456, database username garden_fruit1. $link1 = mysqli_connect("localhost", "garden_fruit1", "123456" ...

After the entire webpage has loaded, the jQuery AJAX method encounters a failure when attempting to update the

I am relatively new to using jQuery AJAX, so please be patient as I try to explain my situation. I am working on implementing a like button for my website that functions similarly to the Facebook like button. To enable users to click on the like button, th ...

Add option button

Is there a way to dynamically add radio buttons using jQuery or JavaScript and save the data into a database? I have successfully appended input types such as text, textarea, checkbox, and select with options. Here is my code: <!DOCTYPE html> < ...

Update the div each time the MySQL table is refreshed

My website functions as a messaging application that currently refreshes every 500ms by reading the outputs of the refresh.php file. I'm looking to explore the possibility of triggering the refresh function only when the 'messages' table updates. While ma ...

How can I use UNION in MySQL or MySQLi to select data without any NULL values and order the results in a specific

I am faced with a challenge in my coding project... $query = "SELECT {$selections} FROM {$table_1} UNION ALL SELECT {$selections} FROM {$table_2} UNION SELECT {$selections} FROM {$table_3} UNION SELECT {$selections} FROM {$table_ ...

What is the proper way to add a NULL value to a decimal type column in PHP?

I am facing an issue with inserting a NULL value into a column named price, which is of type Decimal. The "price" column is nullable and has a default value of NULL. My goal is to insert NULL only when the "price" input field in an HTML form is left empty ...

Experiencing difficulties with the strpos function within PHP

I manage a website dedicated to dog pedigrees, and I'm trying to display images based on whether the dog is a champion. There are various champions like Italian, French, etc. The code for displaying an image works fine for dogs with "CH" at the begi ...

Step-by-step guide: Performing Subtraction of Query Results in MySQL

This is the first query that I've come up with: SELECT DISTINCT(u.nickname) FROM user u where u.id IN(SELECT `submission_user`.`user_id` from `submission_user`) AND u.member_since >= '2015-07- ...

Enhancing Security: Employing Prepared Statements with AES_ENCRYPT and Bind Variables

I've been encountering an issue when trying to encrypt a specific data variable. The error message I keep receiving is "PHP Fatal error: Call to undefined function AES_ENCRYPT()...". After conducting some research, it seems that the problem may arise from ...

Automatically populate fields when the selection changes

Currently, I am facing an issue with a mysql table named clients that I utilize to populate the options of a select in one of the rows. The goal is to automatically fill out 2 input fields with client information when a specific option is selected. To acc ...

Modify database record when an eligible token is supplied

I have a question about the efficiency of my code, specifically line 16 (as commented). Would using $row to compare with a variable mentioned above be more efficient than writing another SQL query? When I tried using a variable and $row['field name'], it ...

Remove a particular row from a table with PHP

I have created a visually appealing table to showcase data in the following manner: ID name Delete 1 abc Delete 2 def Delete The coding snippet used for the aforementioned display is as follows: <?php $con=mysqli_connect("abc" ...

When implementing a function, the new mysqli () object is automatically set to null

Currently, I am utilizing mySQL and php to develop a web application. Within my main index.php file, I include: <?php require_once('includes/config.php'); require_once('includes/functionName.php'); ?> This is the content of my config.php file: < ...

Transferring an Array from PHP to Javascript

I'm attempting to pass a PHP array so that I can use it in JavaScript. The PHP code I have written is shown below: <?php $link = mysqli_connect("localhost", "root", "password", "database"); /* check connection */ if (mysqli_connect_errno()) ...

php mysqli_insert function is not functioning properly with PHP variables

Here is how I am populating a new table with data: foreach ($results as $key => $val){ $sql = "INSERT INTO submission_meta (key, value) VALUES ('".$key."', '".$val."')"; if ($conn->query($sql) === TRUE) { ...

Leveraging MySQL JSON_OBJECT() Function with Prepared Statements

While attempting to add a new entry to a MySQL table, I encountered an issue with the following queries. When using a parameterized query with mysqli, such as the one shown below, it would work smoothly without any errors: insert into notelist(checksum,de ...

Executing repeated statements

Below is the code snippet : try { if(!($stmt = $conn["DB"]->prepare('CALL `central`.`permissions_edit`(?,?,?,?,?);'))) { $rtn["Errors"][] = "permissions_edit Prepare failed: (" . $conn["DB"]->errno . ") " . $conn["DB"]->error; ...

Caution: mysqli_connect(): (HY000/1045): Unauthorized access for user 'root'@'localhost' (using password: NONE)

PHP Notice: mysqli_connect(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: NO) in G:PleskVhostspeacewithoutlimits.orghttpdocsadminincludesconnect.php on line 8 <?php $servername = "local ...

Displaying an array as a column yields no visible results

Yesterday I posted a query regarding displaying an array with commas as columns. You can view the original question here. Today, my progress is as follows: <?php require_once("dbconnection.php"); ?> <?php $sql = "SELECT amount, ingredients FROM ...

Use a dropdown menu to update the selected value

Issue with displaying drop down values in the second list, despite trying various solutions. When a user selects a country, the corresponding state should be populated from the database into the second drop-down. Any assistance would be greatly appreciated ...

problem with relational databases

Establishing a relationship between two tables (login_pre, privilege) looks like this: In the privilege table: +----------------------------------+ | AccessLevel | login_id | pre_id| |----------------------------------| | 1 | 1 | 1 ...

Failed to select mySql database using easyphp with error message "Database selection failed."

Recently delving into the world of PHP programming, I am seeking assistance with database selection code for MySQL within PHP. After creating a database named "admin" through phpMyAdmin, I noticed the name displayed as "[email protected]". To establis ...

Discovering the total count of variables passed to the bind_result() function

I'm uncertain if this question has been raised previously, but how do we determine the number of parameters received by bind_result()? I attempted to retrieve data from a database and used bind_param. However, an error occurred: Warning: mysqli_stmt::bi ...

Can SQL SELECT and SQL UPDATE queries be combined into a single query?

Is there a way to improve the code without using mysqli_real_escape_string's in a single MySQL query? //RETRIEVE VALUES $sql = "SELECT * FROM `fddq_product_lang` WHERE id_product='19627' AND id_lang='3'"; $result = mysqli ...

Is there a risk of collision when using PDO and mysqli at the same time?

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 ...

The number of rows in the $result object never exceeds 0

After sifting through countless threads, tutorials, and various resources, I've reached out here in the hopes that someone can assist me. Despite trying all suggestions provided, I still haven't been able to resolve the issue. Below is my code s ...

Issue with Variable Inside While Loop

Currently, I am in the process of sending out a newsletter using the code shown below. The code involves a $to variable that contains email addresses stored in my database. To maintain privacy, I have implemented a while loop to send individual emails to e ...

PHP is having trouble recognizing bind parameters in a query when multiple parameters are included

Having trouble pinpointing the issue here - when I bind only one parameter, everything works fine. But when both are present, I encounter the following warning: "Warning: mysqli_stmt::bind_param(): Number of variables doesn't match number of parameters i ...

Choosing data based on specific conditions in a database using PHP when the $_POST array is empty and contains a

I am having trouble selecting data from my database using PHP and an ajax call function. In the select function, I am using $_POST to retrieve data from a textbox. Even though I have set up a PHP and ajax call function on my page, something seems to be goi ...

PHP Prepared Statements with MySQLi: Slow Retrieval of Blob Field

To enhance security measures, I have incorporated a function that handles prepared statements. However, an issue has arisen when attempting to retrieve base64 encoded blob data (approximately 30-50KB) through this method. Unsurprisingly, executing the qu ...

What is the best way to iterate over an INSERT INTO query?

I'm facing an issue with executing the INSERT INTO MySQL statement multiple times within each loop of the while statement. Even though the loop seems to be working correctly based on the number of echoes, the INSERT INTO only works once. In simple terms, ...

Using AJAX and PHP to retrieve and store variables in a database

This is my first time attempting this and I'm feeling frustrated because I'm struggling to figure out how everything fits together. I have a function that needs to call two PHP files - one for selecting information from a database, and the other ...

Calculate the number of days between two dates using PHP and MySQL with DatePeriod

I have a DatePeriod object set up using PHP: $start = new DateTime('2016-03-01'); $end = new DateTime('2016-03-01 + 1 month'); $period = new DatePeriod($start, new DateInterval('P1D'), $end); and I also have a SQL Table with work dates: https://i.st ...

Show the form only if the individual is not a member

Having some issues with my code. Individually, the form and PHP script both work fine, but when combined, I run into trouble. <?php $check = $mysqli->query("SELECT is_member FROM users WHERE username = '$username'"); $isMember = $check ...

Verifying the current password and updating the hashed password

I have been struggling with creating a PHP script for updating user hashed passwords. Unfortunately, the script is not functioning as expected and no error messages are being displayed. Every time, it only shows "Your old password is incorrect" message. I ...

The error arises from the automated generation of a table if it does not already exist

Can someone please assist me with this issue I'm encountering? I am attempting to create a table using the provided query, which functions correctly in phpMyAdmin but fails to work within my PHP script. If possible, could you kindly identify any errors in ...

Transform JSON arrays into JSON structure

I'm currently facing an issue with converting JSON arrays to JSON format data. The output I am currently getting looks like this: https://i.stack.imgur.com/SW2NW.png However, I would like my output to be in the following format: https://i.stack.imgur.co ...

Effective method for verifying if a local variable matches another local variable

The comparison fails to evaluate correctly, skipping directly to the else clause even when the values should be equal. The column names in the table match those in the database, so... Should I include quotes in ($recruitcheck==$recruitpass)? $recruiter = ...