Questions tagged [mysqli]

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

Authentication of images along with zip verification in PHP

I am in the process of developing scripts for PHP image validation and zip file validation. While my zip file validation script is functioning correctly, I am encountering issues with image validation. Specifically, I am attempting to add support for jpeg ...

What is the best way to generate a results page by utilizing bind params to display a query selected from a drop-down

I've been diving into an online tutorial to revamp my results page using bind params. Initially, I felt confident in my understanding of the concept but unfortunately, I seem to be hitting roadblocks as it's not functioning correctly. Despite try ...

Utilize the power of MYSQL and PHP in conjunction with an HTML form to

Having trouble with a basic PHP/SQL search bar for my database. The search results are not showing up even though the search bar appears on the page. When I type something, it doesn't reflect in the URL. Below is the code snippet. I am connecting to t ...

What could be causing this prepared statement to consistently display -1 rows affected?

I'm really struggling with this mysqli prepared statement and I just can't seem to figure out what's going wrong. I've spent a lot of time troubleshooting already, so let me start by showing you the code snippet (which is currently only working locally): ...

What is the best approach to updating multiple rows instead of just the first row using the update button located on both sides using PHP and AJAX?

Starting fresh, so I might sound like a beginner with this question. How can I make use of the update button to update specific rows instead of just the top row? Every time I try to update, it only works for the top row. Here's the code snippet from ...

Retain chosen option after form submission in PHP/HTML

I have seen many questions asked about this before, but despite trying various solutions here, none seem to work for me. I am populating a list from my mysqli database: <select multiple="multiple" name="formCountries[]" size="5" id="keuzeproduct"> ...

Can you explain the variance between mysqli_prepare() and mysqli_stmt_prepare()?

This helpful guide explains the usage of mysqli_prepare() in one section, while advocating for mysqli_stmt_* functions in all other scenarios. Alternatively, in another resource within the PHP manual, the focus is on using mysqli_stmt_prepare() Can someo ...

Expanding query with additional JOIN and retrieving table column headings

I'm currently developing a function to convert data into CSV format, but I've hit a roadblock. At the moment, the function is fetching data from two tables and saving it to a CSV file in a single line for each order, including invoice and customer details ...

Uploading pictures to a directory and storing their filenames in a database with the help of PHP

I'm facing a challenge trying to upload 2 files into a folder and save their names and image paths in a database. Below is my HTML code for reference: <input class="field2" type="file" name="file[]" multiple="multiple" /> Here is the PHP code I am ...

Incorporating data from a MySQL database into a PHP page using a variable included in the URL

I am currently working on designing a website and one of the features I would like to implement is the ability to create unique URLs for users. My goal is to have the URL structured as follows: http://www.example.com/page.php?user_id=3 Each user would ha ...

What is the best way to add an insert button to every row?

Take a look at the image provided. When I click on any register button, the last row is being inserted instead of the desired row. What I'm aiming for is this: when I click register, the entire selected row should be stored in a separate table. Whe ...

Having trouble with Codeigniter and Pdo? Getting an error that says "call to a member function

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

Using $_POST to send the database name does not seem to be functioning properly

Can someone help me with a database issue I'm facing? It's been 5 hours and I can't seem to figure it out. When I directly set $dbName="dbTest" in the php file, everything works fine (refer to comments in the code). However, when I try to pass my databas ...

PHP update causing duplicate data to display incorrectly

My team and I are currently working on developing a web application for a company. Our goal is to display various startup companies with different group numbers on this page, while also providing the option to update these numbers. Although the update func ...

What is the best way to store an array of file names in a single column in a database table?

I have a table named t1 with two columns: id and name. I want to insert file names in the name column. <input type="file" name="files[]" multiple></br> <input type="submit" name="submit" value="ADD"> Table: id | name 1 | e1.jpg, e2 ...

Retrieve a record from a database table that is not found in a separate table

I am looking to retrieve a row from the images table that does not exist in the images_viewed table and both share the same name. Although the code I am currently using works, it is causing my website to perform very slowly. $next = $mysqli->query("SE ...

Attempting to implement bootstrap pagination using PHP mysqli

Hi there, I'm currently working on implementing a pagination feature using Bootstrap. My goal is to display all results from mySQL data while limiting the data to 10 entries per page. I would appreciate any assistance with this. Here's the code I have so f ...

The statusText variable for getXMLHTTP object is not found when the status is not equal to

Earlier, I posted about this issue before isolating the problem. Now that I have isolated it, I wanted to repost with a clearer focus on the two functions causing the problem. Whenever I update my State, it triggers the getCity function. The call is being ...

Attempting to output "</ul>" specifically for particular elements within an array

I am currently working on a project where I need to display category names and list any post that belongs to that category in a bootstrap list group. The issue I am facing is how to properly echo the closing <ul> tag at the end of each category so th ...

Just started learning php.mysqli and facing challenges with a select query

I am having trouble with an Ajax call I made to the code below, as it is returning a 500 error. Any advice on what might be causing this issue would be greatly appreciated. Thank you. if isset(($_POST['lodgeChoice'])) { require_once $_SERVER['DOCUME ...

How come when I ask different questions, I get the same response?

Having encountered an issue with two queries in my DB, I am seeking a solution. The queries are intended to return the next and previous rows relative to the current row. Unexpectedly, both queries seem to be returning the same data - only the next row. F ...

Retrieving data from every row in a table using MySQLi for a specific column in PHP

I'm currently facing an issue with populating an array with ID numbers fetched from a MySQL database using PHP. Despite trying the following approach, the array remains empty after attempting to add the IDs retrieved from MySQLi. Can someone help me i ...

Number of database rows - PHP prepared statements - querying data

I'm having trouble figuring out how to retrieve the number of rows from the database using my query. Every time I run the query, it just returns zero even though the data is in my database. $username = $_POST['username']; $hashedPassword = ...

Alert: The function mysqli_query() requires the first parameter to be of type mysqli, but a string was provided in the file path E:OficinaxampphtdocsFormulario-Oficinalistartecnicas.php on

I am facing an issue with my code Alert: mysqli_query() function is expecting the first parameter to be of type mysqli, but a string was provided in E:\Oficina\xampp\htdocs\Formulario-Oficina\listartecnicas.php on line 6 Additi ...

Using AJAX to submit a PHP form without refreshing the page

Currently, I am facing an issue with my PHP and AJAX code for posting data without redirecting the page. Surprisingly, the script works perfectly on the login page but not on other pages. The main difference I observed is that the login page uses if (empty ...

Experience the thrill of receiving a triumphant notification upon submission of your form

I'm currently learning about jquery and how to use it with ajax to insert and display data in a mysql table. I've been trying out some code that inserts and displays records from a mysql database. Right now, my goal is to make the success message appear in ...

Is mysql(i)_real_escape_string a reliable method for ensuring data safety?

function CustomQuery() { $arguments = func_get_args (); if (sizeof ($arguments) > 0) { $query_string = $arguments[0]; for ($index = 1; $index < sizeof ($arguments); $index++) $query_string = preg_replac ...

Utilizing Docker-Compose with PHP (using MySQLi) for seamless connection to MySQL database

Alright, here's the situation: I am utilizing Docker-Compose to set up 3 services - one for the platform, another for a MySQL database, and the third for PHPMyAdmin. I'm currently attempting to use mysqli to establish a connection to the databas ...

Tips for Effectively Adding Deciphered JSON Data into a Mysql Database

I have been struggling to figure out how to get my php code working with my database by searching online, but I'm having trouble understanding it all! That's why I decided to reach out and ask for help or guidance on this issue. Any assistance would be gre ...

PHP Issues with PHP While and ForEach loops causing unexpected outcomes

I am having trouble with my code logic. Currently, I am using a while loop to retrieve associated records for each meal_id. However, my foreach loop is not functioning as expected. My aim is to display the meal information first and then list the meal item ...

How to Establish a Connection Script: Is Unset the Right Choice?

I came across a helpful article that was teaching me how to create a connection script in PHP. You can find it here: However, I noticed that the article defines the unset function differently in two different places, which has left me feeling confused. Fo ...

Avoiding line breaks is essential in mysqli prepared statements

Recently, I made the switch from using "standard" mysqli queries to prepared statements in order to enhance security. However, I encountered a small issue where new lines were being removed when data was added to the database. Below is an example of the qu ...

Attempting to replicate an unreplicable object belonging to the mysqli_result class

why do I keep getting this error message: A severe error has occurred: Attempting to clone an uncloneable object of mysqli_result class each time I attempt to use the clone function on a mysql query result: $result = mysqli_query($con, $query); $resu ...

Periodically refresh database tables every 5 minutes

I am facing a challenge in populating and updating one of my MySql database tables with a complex and expensive query, based on selections from data in another table. The table does not need to be fully updated every time a query is made, but I would like ...

Encountering a snag in PHP/MySQL query without receiving any error message?

I am facing an issue with my code. Despite having a successful database connection, the insert statement seems to be failing without throwing any errors. Surprisingly, even if I deliberately misspell the table name, the page still continues without any e ...

Encountered an unexpected "<" error while using Ajax with MySQL

I am trying to accomplish a simple task - retrieve a table from a MySQL database. Previously, I was using basic MySQL code and it was working fine. However, after switching to MySQLi, I encountered an error: Uncaught SyntaxError: Unexpected token < ...

SQL query that selectively ignores the initial word provided

Can anyone provide me with an SQL query that would exclude the first word from a field and only return the remaining words? For instance: Name: John Smith ABC XYZ PQR Desired Output : Smith XYZ PQR I am looking to extract the text after the ...

updating each row in a mysql table

Hey there, I'm facing a bit of a challenge and could really use some help. I've created a table using Bootstrap v4 to display products along with relevant data. In each row, there are buttons - a green one with a pencil icon that redirects me to ...

Attempting to implement a functionality that will allow users to easily delete records from the database

I've taken on a school project where I am tasked with creating a login/registration form. Additionally, I need to develop functionality that allows users to register, login, view records, and delete records from the database using a dropdown menu and ...

The conversion of mysqli_result to an integer could not be completed

When attempting to store the results of an SQL COUNT in a variable and then divide them, I encountered an error message that reads: Notice: Object of class mysqli_result could not be converted to int in ---- $countrows = 'SELECT count(*) AS NumRows ...

Unable to deactivate account, experiencing technical issues

After running once, the code in deactivate_myaccount.php throws an error stating: "Notice: A session had already been started - ignoring session_start() in C:xampphtdocsincludesincludesheader-inc.php on line 2". Furthermore, the intended functionality ...

Assistance required with transferring variables between PHP classes

In my code, I have a 'Database.php' file that is responsible for managing database connections and passing MySQL connections to classes that require the Database functionality. Within the 'Database.php' file: <?php class Database ...

What steps do I need to take to establish a local connection between PHP and MySQL?

I'm currently testing a PHP website on my Ubuntu 16.04 machine, but I am facing issues with connecting to the MySQL database using mysqli_connect(). My setup includes Apache 2.4 with mod_php7.0 installed. I have also added the php7.0-mysql package in Ubun ...

When the statement is enclosed within a while loop, an empty tag is not

Working on a custom website for a non-profit organization and I'm stuck on the search page. Here's what's going on... The search results are showing up, but when there are no results, nothing is displayed. I can't seem to figure out this issue. while($r ...

A search form utilizing prepared statements in mysqli

Well met again, everyone. I recently reached out for help on improving some messy code I had put together, and the response was swift. Thank you for that! You can find the original question thread here: PHP - Search database and return results on the sam ...

When using mysqli_query(), I seem to be missing parameter 1 and I'm having trouble identifying the mistake in

class AirData{ function __construct() { $this->connect(); echo "start"; } function connect(){ /*establish secure connection to the database using PDO*/ $connection = mysqli_connect('localhost&ap ...

Removing information from a database using a dropdown list in PHP

I'm encountering an issue with deleting data from my database using a drop-down menu. This is how my drop-down menu looks <form method="post" action="admin.php"> <h3>Delete a user</h3> <select name="username"> $sql = mysqli_query($ ...

The numerical row is not being detected within the table

I am currently developing a login system for a news website as part of my coursework. However, I am facing an issue where the if statement using $rows->num_rows == 1 always executes the "else" code. This means that it is not detecting a row in my database ...

Using PHP's mysqli function to generate a JSON array

Currently, I am in the process of learning php/mysql to enhance a website that I am constructing. Initially, everything was functioning as intended but there were numerous vulnerabilities and security flaws with minimal error handling mechanisms. To addres ...

Encountered a "MySQL server has disconnected" error while preparing a mysqli statement

Struggling with the transition from Procedural to Object Oriented programming, so please excuse any untidiness or errors in my code. Here is an example where I am passing posts through jQuery to a class for updating a record when a user checks a checkbox: ...

Generating an HTML table from SQL data using PHP

I'm attempting to create a dynamic HTML table using PHP to populate it with data from a MySQL database. I've tried using a while loop, but the issue is that it ends up displaying the same first row multiple times. <div class = "container"> & ...

Resolving MySQLi Error due to Incorrect Usage of MySQL Variable

After a long time of receiving help, I have finally created my account here. However, this time I couldn't find an answer to my question. I am new to MySqli and I am currently attempting to run a script that previously worked in phpMyAdmin. The issue ari ...

Unexpected server error encountered during navigation of php pages

I am using PHP to retrieve data from a MySQL table and display it in an HTML table. Each row in the table has a 'remove' button that triggers a PHP script (remove.php) to delete the corresponding row from the database table and return to admin.php. However ...

Despite displaying a 'Couldn't fetch mysqli_stmt' warning, the insert query successfully transmits the data to the database

I have a form on my website that contains two dropdown lists. Both of these dropdowns are populated with values from the database tables. When a visitor submits the form, certain actions are triggered: A SELECT query is used to compare the selected choic ...

Issue "It seems like the mysql extension required by wordpress is missing in your php installation" encountered on Ubuntu 18.0.4 with PHP version 7.2

After upgrading my Ubuntu version from 16.04 to 18.0.4 and updating PHP to 7.2, I encountered a problem trying to log in to my Wordpress websites. The specific error message reads: Your php installation appears to be missing the mysql extension which is ...

Can mysqli_real_escape_string prevent SQL injection attacks?

Is it possible to exploit the following code in order to log in as a specific username, such as Sam? The mysqli_real_escape_string() function is used to escape certain characters including NUL (ASCII 0), , , , ', ", and Control-Z. I attempted with us ...

Original code

I have a database containing HTML code for a table. I would like to display this code in its original form within a textarea so that I can edit it. However, when I try to echo the code, it appears in compiled form as a table rather than the original HTML ...

What steps do I need to take in order to switch from using INSERT INTO to

(Apologies for any errors in my English writing) Here is the code I am using to insert data into my database: $insertChecklist = 'INSERT INTO checklists(`ADMIN_ID`, `COMPUTER_ID`) VALUES(?, ?);'; $stmtChecklist = $connection->prepare($insertCheck ...

What's the least amount of pagination we can get away with?

What is the simplest form of pagination in PHP/MySQLi? I have done some research online and attempted to learn how to implement pagination, but all the examples I found were quite complex. I am looking for the bare minimum requirements to get started and g ...

I am having trouble inserting my data into a MySQL database via PHP

I am currently tackling a school project and struggling to complete the registration page accurately. The data does not seem to be getting inserted into the table as intended. Please take a look at this screenshot of the database and table After reviewin ...

Unable to remove a particular entry from the table

Having trouble with deleting just one row or record? Finding articles that don't quite help, and ending up deleting the entire table instead? <?php // set database connection details $databaseHost = 'localhost'; $databaseName = ...

In PHP, single quotes present a challenge for prepared statements when it comes to escaping

When I was faced with the issue of single quotes causing problems when inserting values into MySql for sign up, I turned to prepared statements as a solution. Previously, I had used addslashes but found that it only worked for specific queries. Let me elab ...

Experiencing difficulties while transitioning to MySQLi for updates

After spending some time delving into MySQLi, I am facing a challenge in updating a script with new functions. The script is utilized for a dynamic dropdown form that receives data through JS. To get a better idea of what I'm referring to, you can vie ...

Retrieve names from MySQL database that contain both spaces and do not contain spaces using the `mysqli` function

I am looking to display rows where the 'tipster' column matches the option selected by the user in the form input. I attempted using replace (tipster ' '. '') LIKE '$tipster' but did not receive any results... Some fields have spaces while others don't - ...

Exchanging information of the table with one another

Greetings, I am a technician specializing in the repair of PCs and laptops. Currently, I am working on developing an offline database website where I can store information about repairs, clients, and invoices. My understanding of SQLi and PHP is quite basi ...

Troubleshooting Problem with Prepared Statements in PHP/MySQL

Currently, I am working on a PHP/MySQL project and have encountered an issue that I need help with. The project involves creating a platform where users can input their financial accounts (such as bank accounts and credit cards) along with monthly transact ...

Omit records that are already present in a different table

Recently, I have set up 2 tables that look like this: emails: emailID int(10) auto_increment, memberID int(10), emailData text, and so on members: memberID int(10) auto_increment, user_name char(40), password char(50), and so on My current query looks l ...

Assistance with using prepared statements

Greetings everyone, I recently learned that using prepared statements is the most effective way to protect my website from MySQL injections and related security risks. However, I'm encountering an issue that I can't seem to figure out. Here' ...

Converting Mysqli to PDO for PHP and Ajax Infinite Scroll functionality

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

"Implementing MySQLi Bulk Prepared Statements for Improved Performance on a High-Tra

After scouring through various online platforms, including Stack Overflow, I have yet to find the ideal solution for my questions. I am currently working on developing a massive information management system in PHP and MySQL. I recently updated some code ...

Changing password using mysqli in PHP when a fresh one is provided

Being relatively new to PHP and mysqli, I feel like I might be approaching this the wrong way. Maybe I should be checking if the password needs to be updated when it's not the same? However, I'm uncertain about how to go about doing that. Curren ...

Ideas for displaying data or a message only once when selecting multiple checkboxes in jquery

code: <script> $(document).ready(function(){ $(".choose").click(function(){ job_type = $(':checked').map(function() { return this.value; }).get().join(',&ap ...

Is it possible to retrieve information from a MySQL database by utilizing Bootstrap and Ajax with the selected ID?

I am currently working on two php pages. The first php page contains a table with records that can be edited using a Bootstrap Modal, while the second php page processes updates to the MySQL database. Below is the code for the first php page (edit_account ...

Using mysqli to pass a constant in bind_param

Is there a way to pass a constant to the bind_param function in mysqli prepared statements? When I try to pass a variable, it works fine: $stmt->bind_param("i", $id); However, when I attempt to pass a constant, it does not work. For example: $stmt-& ...

Dynamic Data Visualization using ChartJS with MySQL and PHP

I'm trying to create a line chart using chartJs that will display MySQL data. Specifically, I would like to use PHP to push the MySQL data to the chartJs. Here is an example of the MySQL table: id | page_views | visitors | month | --------------------- ...