Questions tagged [php]

Use ONLY if PHP is directly relevant to the question and likely to be the source of your problem, not just because you're using a PHP library to connect to a database. PHP stands for Professional Hypertext Preprocessor, a widely used platform for dynamic web applications. If you have a general programming question about PHP, please ask it on Stack Overflow instead.

Filter by
Sorted by
Tagged with
-1
votes
0answers
5 views

How do I use PHP to construct an SQL query to sort and select from multiple rows in my database

I'm building a game using a platform called Unity. The game integrates with some php scripts and a database I have. Players can register in the game and all info gets stored in the database, including ...
-1
votes
0answers
12 views

i have to store image field data in image table and category field data in category table from a single form using php [on hold]

// enter code here <?php session_start(); if(!isset($_SESSION['email1'])) { header('location:admin-login-form.php'); } ?> <?php $con = mysqli_connect('localhost','root','root'); ...
0
votes
1answer
11 views

MySQL query takes too long in codeigniter

I've made this query SELECT id,name,iupac_name,inchi_key,molecular_weight,molecular_formula,exact_molecular_mass FROM compound WHERE name LIKE '%quer%' OR iupac_name LIKE '%quer%' OR ...
0
votes
1answer
16 views

How to perform strictly SQL query that uses multiple values and searches all fields

I'm trying to create what I would call an "inclusive" search and by that, I'm not referring to "between". I have a snippet of code and it does what I need it to do but it's hacky and inefficient so I'...
0
votes
2answers
166 views

How can I model a database structure to retain student information?

I am completely new to databases and SQL. I have generated a database in myphpAdmin consisting of a table with the columns (name, student number, grade). Basically this database will hold the grades ...
1
vote
2answers
298 views

implement geo / spatial / proximity search with php and mysql — what have you done successfully [closed]

For my website's users, I want to implement a worldwide geo / spatial / proximity search with php and mysql. I want to do this as simply and minimally as possible. What is the minimum data I should ...
2
votes
1answer
718 views

MySQL Stored Procedure not throwing error if it contains a query that succeeds

I am writing a simple MySQL Stored Procedure, and calling it from PHP using PDO. This is just simple enough to illustrate the problem I'm having. This procedure test_procedure_2, does not throw any ...
0
votes
1answer
248 views

Extremely slow website, MySQLTuner log, any advice?

We are running a Wordpress site and are having major problems with extremely slow response time for pages that have to miss the Nginx cache. I'm looking at our database performance as a culprit, and ...
0
votes
4answers
2k views

Order by numbers followed by alphabet and then null values

I have below column in my database: abc 1 2 null 100 6 I want to sort and show these values as per below sequence: 1 2 6 100 abc null Anyone please help me to solve it. Consider below query: ...
0
votes
2answers
19 views

Value of prepared statement is listed as error in query string

I have made a Wordpress plugin that writes some data to a proprietary table. The query as shown in the log is: INSERT INTO berichten_devices (device_UUID, article_id) VALUES (%s, %s) If I take ...
0
votes
1answer
156 views

Optimal way(performance wise) to store array like data in MySQL

I am working on a website(PHP), and one of the features that the site should have is ordering items from the website, and the order will be like an array with an architecture similar to this: order( ...
0
votes
1answer
163 views

How to find the most common phrases in a MySQL database

I have a table which contains articles on movies. Each article has a title and many of them have common phrases in them. I would like to do some analysis on the data and extract these common phrases ...
0
votes
0answers
22 views

Why does this query return a result in MySQL but not in php?

I have a query that isn't returning a result in php for a certain search term (that I believe it should), but when I test it directly in MySQL, it does return one. Other search terms return fine. ...
0
votes
1answer
14 views

How to prevent a record from being affected by the ORDER BY RAND statement in MYSQL

I have a series of problems all which I can't put in the title but I will try to explain them as best as I can. I am building an online exam platform with PHP and MySQL. Problem 1: Prevent a record ...
1
vote
0answers
18 views

How to prevent a record from being affected by the ORDER BY RAND() function?

I am building an online exam site using php and mysql. It's just for MCQ type questions. Here is my database structure: 1) QUESTIONS ( Exam_ID, Questions_ID, Questions_Des) 2) OPTIONS ( Question_ID, ...
0
votes
1answer
156 views

MySQL Query logic for filters for wordpress site

I'm a WordPress (PHP) developer, however I have not done a lot of complex MySQL queries. I am working on an events website and want to create filters: User should be able to filter events by the ...
0
votes
0answers
18 views

How to show dynamic data row to data column in mysql or within php?

I have problem with query mysql. So I have database table and I've tried with my query like this SELECT GROUP_CONCAT( 'MAX(IF(day(tanggal) = ', day(tanggal), ', presensi, NULL)) ...
0
votes
1answer
33 views

Results not returning rows where second parameter should match null

I'm trying to left join three tables using columns from the first and third tables as the filters. The second and third tables could have null values where I am trying to join. I want to be able to ...
0
votes
1answer
213 views

Tracking MongoDB execution times using PHP

I am currently working on a project using PHP, I have done research and found that microtime() helps with tracking the time of a query in a MySQL database.. how do I do the same for MongoDB, I have ...
1
vote
0answers
40 views

MariaDB DELETE not removing all rows

I'm managing a MariaDB server and I noticed that an application run a DELETE query in a table each time the entity was saved and then it will insert the new rows referenced that entity. Sometimes ...
173
votes
11answers
408k views

connect to PostgreSQL server: FATAL: no pg_hba.conf entry for host

Hello I am trying to run a website sent to me but after doing so this error appeared connect to PostgreSQL server: FATAL: no pg_hba.conf entry for host "4X.XXX.XX.XXX", user "userXXX", database "...
0
votes
1answer
299 views

Optimising Marksheet Database

I am trying to design a database for mark sheet data of a school having different types of exams of different levels or class. Is it possible to have single table where I can store data in string (...
0
votes
0answers
27 views

How to prevent inserting same value in two columns in one Table?

I'm trying to solve problem which will compare BEFORE INSERTING columns values partnerCode and partnerCodeOwner1 with username in the table below, If partnerCode and partnerCodeOwner1 values same with ...
0
votes
1answer
17 views

Best Approach for PII and Databases

PII, or Personally Identifiable Information, involves information that may include the following, among other data: First Name Last Name Email Address Phone (any of them) Billing Address Shipping ...
0
votes
1answer
48 views

How can I write a trigger that can subtract values between two tables

I have a table called transaction that has these fields CREATE TABLE transaction ( transaction_id INT AUTO_INCREMENT, status varchar(255), myPIN varchar(255), amount_paid varchar(255)...
0
votes
1answer
333 views

sybase errors - meaning and resolution

We have a server that connects to 40+ different remote computers which are running Sybase 11.0.1.2596. Our server is hosted on an aws ec2 AMI Linux instance, and the connections are set up using ...
0
votes
1answer
26 views

MySQL: Can not add foreign key into create table statement

The queries below (assigned to php variables) seem to have an issue on the 2nd query, where I set the foreign key to the "couponId" column on the first table. My IDE lints "couponId" (inside the ...
1
vote
0answers
22 views

MongoDB / PHP - How to change data type for every occurrence of field in a document

I'm trying to learn how to use MongoDB with PHP. I Have built a web application that loads data from database etc. The issue I am having is that when I import my data from a .CSV using MongoDB Compass,...
-1
votes
1answer
38 views

How can I capture user IP address and store them automatically to my database? [closed]

am currently running an open voting system with no login form. I wanted to restrict double voting using user IP Addresses, how can I record user addresses direct to my database and use them to ...
2
votes
3answers
1k views

How to select different format of the date in mysql

0 down vote favorite. I have this table and I can't change its format to yyyy-mm-dd because I have so many scripts that are related to this format dd-mm-yyyy. It would be a mess if I change its ...
0
votes
1answer
37 views

Cannot connect to MySQL using PHP 7 [duplicate]

The version of MySQL is 8.0.16. This is installed on an EC2 Linux and is a fresh install. I have run the mysql_secure_installation command after installation and was able to change the root password ...
0
votes
1answer
383 views

MySQL / MyISAM: Queries sometimes very slow, no waiting for lock time

I have a web application using PHP 7.0 and MySQL 5.5.54-0+deb8u1-log. Occasionally, there are long waiting times in the application, which seem to be related to slow database queries. In the slow ...
0
votes
1answer
871 views

PDO Select all tables who are beginning with a prefix

I have a lot of tables in my database and some of them are beginning with a prefix "amb_" egsample: "amb_users", "amb_locations" "amb_friends" etc Any Idea how to select all tables who are ...
0
votes
1answer
61 views

Php PDO Get all column names from table in specific database

I currently have the following query. Which fetches all column names for a table. But when there are 2 tables with the same name (in different databases) it fetches those column names as well. In ...
0
votes
2answers
493 views

mysql - best way to provide unique voucher

I am designing a website that will provide vouchers (serial codes). All voucher codes generated and saved in a table like this and not generated online: v_id voucher ...
0
votes
1answer
504 views

MySQL MyISAM REPAIR TABLE lost connection to MySQL server during query

So I've been building up over time a database, and unfortunately I was using MyISAM which didn't have any problems until the database became huge. After massive CPU spikes, I created a script to ...
-1
votes
1answer
27 views

Group Concatenate In mysql

Please can some one help me out of this. I have two tables, One is like this And the other is like this How can i use one mysql query to insert all users subject, total scores of those terms to ...
0
votes
0answers
11 views

mysql-5.7 and php5.6 - error on LONGTEXT Field type saying a 387 character long string cant fit in

Ok Here is my frustration cause: I've got this table structure: CREATE TABLE `blog_post` ( `bp_id` INT(11) NOT NULL AUTO_INCREMENT, `user_fid` INT(11) NULL DEFAULT NULL, `cat_fid` INT(11)...
2
votes
1answer
907 views

MySQL deleting lots of rows by id - where in or loop over each row in transaction

I have a delete query which is potentially going to delete tens of thousands of rows. Currently it's taking quite a long time in the more extreme case (over 100000 rows to delete) using this: ...
3
votes
1answer
940 views

PHP MySQLi Lock Tables Query Sometimes Does Not Complete

I am attempting to lock some tables while running some code and unlocking the tables when I am done. Process: Run Lock Tables MySQL Query. Run some PHP Code. Run Unlock Tables MySQL Query. While ...
-6
votes
1answer
24 views

I want to make drop down elements compulsory but unable to do so in php file [closed]

I want to make it compulsory for user to select one of the option in city , if he will not select the drop down option , the form will not submitted. But it is not happening...following is the code... ...
1
vote
2answers
6k views

Load csv file to mysql using load data local infile

I need a simple way to load a csv file from my computer to the database (which is on a remote server). I'm trying to load the file using a php page that executes this code: $file = $_FILES['csv']['...
0
votes
2answers
92 views

error while converting sql to eloquent query [closed]

I have converted an sql query to eloquent like below: $roomtypes = DB::select(`rt.id`,`rt.type`,`rt.total_no_of_rooms`) ->addSelect(DB::raw(`SUM(r.no_of_rooms) as reserved rooms`)) ->...
1
vote
1answer
880 views

MySQL/Pivot table for two tables

I was trying to get multiple rows into a single row with dynamic columns created as per the data. I have two tables combined with foreign key. Table 1: | id | name | Invoice value | invoice_date | |-...
1
vote
2answers
3k views

MySQL: SELECT GET_LOCK slow/timeout

I am using "Zebra Session" as a replacement for PHP's built-in session management. Zebra Session stores sessions in a MySQL database, and uses "session locking" in order to ensure that data is ...
0
votes
1answer
35 views

Mysql join query improvement and GROUP_CONCAT on GROUP BY

I have two tables which I need to perform a left outer join on to get the result set I want. The query I have now works but its taking too long to process. Any suggestions? Query: SELECT Date_format(...
0
votes
0answers
74 views

mysql8 gives “Access denied for user” error with php but not navicat/workbench

I have been reading billions of answers/questions for that same error : SQLSTATE[HY000] [1045] Access denied for user 'root'@'ALEXPC' (using password: YES) I myself even handle this error like ...
1
vote
1answer
915 views

MySQL help do I use Where not exist or Join? - Laravel

I have two tables as follows: 1) urls id domain created_at ------------------------------------------------ 1 google.com 2016-11-30 00:00:00 2 test.com ...
2
votes
5answers
34k views

Insert if NOT EXISTS not working

I am trying to copy data from table to another mysql table from two different databases First I get all data from first table and stored them into php variable then I loop on that var to insert data ...
0
votes
2answers
280 views

Parameterized Queries in PostgreSQL using PHP fail to handle null values

I'm using PHP and PostgreSQL on OpenBSD 6.1, with pg_prepare and pg_execute to effect parameterized queries. $rs = pg_prepare($con, base64_encode($query), $query); $rs = pg_execute($con, ...