Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now

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
22 views

multiple types of info display from mysql db [migrated]

I have received great help and direction here recently so I'm back! The project is gathering a list of available care facilities and have the user be able to search the dB. So, i have the ...
-1
votes
0answers
5 views

SQL PHP can i check owner name and if it exist select it but if not select default 0 [on hold]

I want, when i agree 1 job i am owner in this job and other agents can not see this job but then i refresh this site if i have 1 active job i can not see other jobs, i can see only own job right now ...
-1
votes
0answers
42 views

How to ORDER BY start with field that IS NOT NULL

As shown in Image below my records from this MySQL query - SELECT action_items1, action_items2, action_items3, action_items4, action_items5, action_items6, action_items7, ...
0
votes
1answer
40 views

Count up numbers from a specific column [closed]

Hi there was wondering if someone could help me out, and can give me a little code example. i have a table named "projecten", and columns named "pstatus and pafgifte" these columns have numbers only. ...
0
votes
1answer
16 views

Azure database - unable to locate in my Azure account

I have an Azure account where a developer that used to work with me has set up an MSSQL database on an Ubuntu VM. The PHP (CodeIgniter) system I am working on logs in (so database queries work ...
0
votes
0answers
23 views

Aborted connections (Erros reading communication packets)

I set up a new Database Server over a SQL Dump with innoDB MYSQL 5.7 from MYSQL 5.6. The Server running external with many sleeping SMTP connections over 1 Mio a day. I made the server open for ...
0
votes
1answer
29 views

Performance MySQL query with for loop

In this method, first I have to get sundays dates between two dates, in this case about 1 year. Then I go through the dates in a for loop and set them to the query. I use prepared statements to make ...
0
votes
2answers
103 views

Generate invoice number from 0 to so on for ordered products in orders table in php mysqli

I am trying to generate invoice number in orders table, like if user select 1 or multiple products and add it to cart then place order then invoice number should be same in our orders table for that 1 ...
-1
votes
1answer
38 views

Displaying data horizontally in mysql [duplicate]

I have this table in my db id | major | code_lesson | files Which the contents look like this id | major | code_lesson | files 1 | Math | MAT12 | mat.pdf 2 | Socio | SOC15 | soc.pdf ...
1
vote
1answer
26 views

Should I use VARCHAR or DATETIME?

I am making a blog cms system and the release date and time of the posts should be shown on my site. Should I save the Datetime in the php code with a function and save it in a varchar in the ...
0
votes
1answer
15 views

How to select 3 records before x ID and 5 records after x ID with Laravel Eloquent?

How can I select 3 records before x ID and 5 records after x ID with Laravel Eloquent or mysql?
0
votes
3answers
138 views

How Can I clone a database in Microsoft SQL server using PHP?

I am creating a portal where user can create the b2c or b2b store itself, so I need to clone the sample database to perform the task. It's not looking simple to clone the database in MSSQL. Please ...
0
votes
1answer
50 views

Change Data Capture in MySQL/PHP by writing to a MySQL table (rather than streaming to Kafka/Rabbit/etc)?

I have a small internal web app I'm developing with PHP and MySQL. I'm looking to sync client webpages to a server by requesting all changes since a certain date. I've found a number of solutions ...
0
votes
1answer
18 views

App Engine Standard connection to Cloud SQL Latency Randomly

I have a pretty "basic" app that we designed that was originally on a local plesk server and we migrated to GAE/GSQL/GCS. app engine, mysql, cloud storage. Here's some background info: App is PHP ...
1
vote
0answers
24 views

Multiple join with self join in MySQL and split column in row

I have four tables "Commission" , "Vendors", "Accounts" and "comsplitconfig" like commission Table commissionid vendorid accountid sales commission 1 V1 A2 ...
0
votes
1answer
60 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
17 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
21 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
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. ...
1
vote
0answers
20 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
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 ...
0
votes
0answers
36 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 ...
1
vote
0answers
52 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 ...
0
votes
0answers
30 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
50 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
50 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
29 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
48 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
41 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 ...
0
votes
1answer
117 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
201 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
0answers
18 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)...
-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... ...
0
votes
0answers
188 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 ...
0
votes
0answers
98 views

Calculate the SUM amount in daily basis Expense in sql/php

I want to get the total amount of Expenses in dail basis, if there is not Expeses posted/inserted THEN echo zero. this is the Code i have tried <?php $sql = "SELECT date(date) as td ,...
-2
votes
1answer
22 views

How to retrieve a users uploaded files using foreign key

I have two tables,users, and,files, Users Id,firstname,lastname,email,password files Id,filename,description,userid Userid in files is foreign key witch relates to Id in users I am trying to ...
0
votes
0answers
185 views

PHP slow with remote MySQL

I run ubuntu 18.10 and I've run into issues with a remote database server. I connect using a private network (by IP). The query in bash mysqlcommand takes about 9ms, while in the PHP software (eg. ...
1
vote
1answer
42 views

Mysql multiline statement causes syntax error

// php, using wordpress to send a raw query string $output = $wpdb->query(" INSERT INTO wp_priceGrids (gridId) VALUES (NULL); SELECT MAX(gridId) FROM wp_priceGrids; "); Results in: ...
0
votes
1answer
23 views

viewing a column in mysql database using php script

I'm trying to print a row from a table in mysql using a PHP script - here is the code but its not working - it shows Bad query apparently there is no issue: $conn = mysqli_connect($servername, $...
0
votes
1answer
37 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
1answer
101 views

Mongodb find() not working as expected, PHP [closed]

Mongodb find() seems Not to work, I have tried all I could and nothing works so far. using PHP7+ I have a Document in the strure like the image below In SQL I could do something like:SELECT....... ...
0
votes
1answer
121 views

Fetch records only for today's date by using PHP & Mysql

I have a column in my table as date and time format like YYYY-MM-DD HH:MM:SS And i want to fetch data which was stored on current date only, everyday I'll be getting data for 24hrs only,
2
votes
1answer
684 views

How to join 2 tables in mysql but with different values in one of the tables

I have 2 tables(as shown by the image below) inbox_messages_table and users_table So what i am trying to do is combining the 2 tables ON user_id but in my inbox_messages_table i have an id which i ...
0
votes
1answer
18 views

Why does the column content say “Array”?

I got this problem when I'm doing mysql that every time that I post pictures on the blog it will say to the database that I got array on image column. it is supposed to have the image that I inserted
0
votes
1answer
20 views

Pulling a username from table one to update credits on table 2 under the same username

I currently have 2 tables, one being a table that stores votes, and the other being the members table. I want SQL to pull the username from the "votes" table (as this keeps track of who voted), then ...
0
votes
0answers
558 views

Sync local mysql database and live server database?

Someone answer the question on the below but he did make it clear, I can't see code where he connect to Database how to combine the file (Footer.php, Config.php, Sync.php, sync_server.php) Please I ...
0
votes
0answers
181 views

PHP-FPM Can't connect to Mysql via localhost but can by ip

Using mariadb 10.2, php 7.0, in Centos 6.9 hosted cpanel server. Everything is installed and compiled through cpanel. If I put PHP into FPM mode it cannot connect to DB unless I specify 127.0.0.1 ...
0
votes
0answers
78 views

Improving/ Optimizing Performance Query in MySQL PHP

I have a invoices, invoices_items, order, order_items. Invoices and Orders tables contains around 1 Millions records. Invoices_items and Orders_items tables contains more than 2 Millions records. ...
1
vote
0answers
29 views

Weird MySQL column name issue

After trying to use the Propel PHP ORM on my database, I noticed that there is an issue with foreign keys. This is a table with foreign keys: CREATE TABLE `appusers` ( `AppID` INT(11) NOT NULL, `...