Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

0
votes
0answers
18 views

Quiz System Database Schema [on hold]

I want to create a database schema for quiz system which is little different from the rest of the typical schema(s). As we are all aware of the entities involved in it which are therefore Quiz-type(...
0
votes
0answers
22 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
13 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
15 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
16 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
22 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
0answers
11 views

How to save mail in send folder using codeignator [migrated]

I want to send email using codeignator mails are sending properly but not saving in send folder i have put code below. public function sendMail() { $data=array('fromEmail'=>'xyz@gmail....
0
votes
1answer
22 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
0answers
9 views

Php MongoDb Close Connection [migrated]

I am using php mongodb driver in my application, But I am facing an issue with this as I have 16 load balancers and only one mongodb server my mongo shuts down when there is lot of load. The new php ...
0
votes
1answer
29 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
8 views

if Operator in PHP not working as it should be [migrated]

I am fetching data from excel file in php there is a field data written (Emp. Code ) when i match as it is same in php if condition like this if($Dt2 == "Emp. Code ") its not working but i tried ...
-1
votes
0answers
126 views

Trying to SUM two separate columns but not together as part of a search result - Updated

Code below: $db = new PDO($dsn, $username, $password, $options); $db1 = new PDO($dsn, $username, $password, $options); $db2 = new PDO($dsn, $username, $password, $options); $sql = "...
0
votes
1answer
29 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
24 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
125 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
17 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
16 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
118 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
37 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
34 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
26 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, `...
0
votes
0answers
13 views

How to get single row data into a row with multiple columns [duplicate]

I have a table as follows: Id Movie_name Person_Name Role_Name 1 mov1 xyz Singer 1 mov1 pqr Dancer 1 mov1 abc Actor 2 ...
0
votes
1answer
19 views

Accessing mysql database without logging in (from android java application) (using php server side) [closed]

Just like all e-commerce applications (like amazon) let you access the database and browse items without logging in or signing up, how can i do this with mysql database (without logging in with ...
0
votes
0answers
34 views

PHP - mysqli::real_connect(): (HY000/2002): Invalid argument in file

On a work project, I'm load-testing a php service on MySQL 5.6 loaded on a beefy Google Compute Engine VM. After I exceed a certain amount of requests per second in my load test, MySQL starts giving ...
2
votes
0answers
49 views

SQL Server stored procedure not throwing certain kind of error

I noticed an issue in my app recently where an database insert that occurred in a stored procedure was failing, but no exception was getting thrown. The insert failed because a column that doesn't ...
0
votes
2answers
65 views

Most performant design for each member to manage his/her own news list?

Say a news website has news categories such as Politics, Business, Society, Education, Health, Tech, Celebrity, Lifestyle, ... etc. The number of categories may be more than 20. New categories may be ...
0
votes
1answer
34 views

Get total row by month in multiple tables [closed]

I am new in Oracle database and php, I tried to create a monthly report which covers the whole 12 months of a year. Currently I have 5 different tables which will store data every month for one year. ...
0
votes
1answer
31 views

Using a DB2 merge with conditionals for matches?

Within a PHP script I'm running a working merge but I need to add date conditionals to it, and my updates cause it to no longer work. The logic I'm looking for is this: If there's a match AND the ...
0
votes
0answers
116 views

Display Dynamic Pivot MySql Table to PHP

i need help on how to display this on html or php. i have this dynamic pivot table code. SET @sql_dynamic:= (SELECT GROUP_CONCAT(DISTINCT CONCAT('if(sum(if(attendance_date = "', ...
0
votes
0answers
4 views

Submit values to mysql data base form a form in side another form together

I have some questions on php. imagine this form <form> <input type="text" name="name"> <form id="second" onsubmit="return false;"> <input type="text" name="name1"> </form&...
0
votes
0answers
38 views

Connecting to MS SQL Server database via PHP

I’m new to SQL, databases and PHP, and I’m trying to find out the way to query my MS SQL Server database via PHP. I understand I must first establish a connection to the database which is accomplished ...
0
votes
0answers
34 views

Need an efficient mysql database schema to store points/ratings

I have four main tables- 1.user(user_id, name,...) 2. post(post_id, description, ...) 3.comment(comment_id,user_id,comment,...) 4.reply(reply_id,user_id, reply,...) and 5.user_post(user_id,...
0
votes
3answers
17 views

MYSQL: Display NULL value when foreing key is NULL

I have the following database structure in MYSQL: CREATE TABLE xs_bugtracking ( `id` INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, `product` VARCHAR(64) NOT ...
0
votes
1answer
43 views

Help in mysql query

I have a column in database with name paid_amount that have multiple values with a separator like: 1,2,4,10 I need the sum of these values: sum = 17 select sum(paid_amount) from invoices where ...
0
votes
1answer
633 views

Postgresql 10 There is no unique or exclusion constraint matching the ON CONFLICT specification

I currently have a table which looks like this: CREATE TABLE "PDPC".collection ( col_no bigint NOT NULL DEFAULT nextval('"PDPC".collection_col_no_seq'::regclass), q1 character varying(10000) ...
0
votes
1answer
55 views

MYSQL ONLY RIGHT JOIN WHEN LEFT SIDE NULL

my English is not that good, so translated with Google Translate. Have been able to fix many problems with this site anyway, thanks to all active users here. Unfortunately I have to ask my first ...
0
votes
0answers
33 views

SQLITE PHP Like Query wont return results on all rows

I have created a SQLite query in PHP which queries user input and checks it against the database, however when I run the query it just displays everything in the database. and if I was trying to ...
1
vote
1answer
82 views

Prepared statement too slow

have an issue with MariaDB 10.2.12 running in aws rds (single master, no slave) when I run prepared statement using a variable substitution PREPARE stmt1 FROM "select ...quite complex select from ...
0
votes
2answers
135 views

UPDATE with multiple WHERE and SELECT condition - MySql

So, I have two tables ativos and colaboradores and they are linked by id_colaborador (FK) on my update page, I'm able to change the id_colaborador but instead of changing the ID I want to write the ...
1
vote
1answer
47 views

Is it possible to output multidimensional data from linear table without iteration?

I have the following table on a cycling club's website: CREATE TABLE `mileage` ( `id` int(11) NOT NULL AUTO_INCREMENT, `rideID` mediumint(9) NOT NULL, `rideDate` date NOT NULL, `isWeekly` tinyint(...
0
votes
1answer
21 views

Why is this blob saving when used as a concatenated string but not as a prepared statement

I have a PHP mysqli prepared statement that looks like this: $editSQL = "UPDATE tblClientReminders SET Header = ?, Notes = ?, DepartmentID = ?, TierID = ?, RemindType =...
2
votes
2answers
308 views

How do I use 'N' in my prepared SELECT statement

I'm connecting to an SQL Server 2008 database using pdo and the ODBC Driver 13 for SQL Server. I'm trying to run the following query which searches the database for Chinese characters: SELECT TOP (...
1
vote
0answers
69 views

MySQL count rows of multiple tables for each user

I basically need this with some adjustments, I just can't seem to figure it out how to do it. I need to sum the rows of two tables, for example: SELECT student.StudentID, student.`Name`, COUNT(...
8
votes
2answers
258 views

How to create recurrent weekdays as columns in a pivot?

I am newcomer to programming and databases and I would be grateful for some help on the following scenario. I use PHP with SQL Server. I am building an employee attendance system and I would like to ...
0
votes
2answers
29 views

How can I select the next available row id of varchar type in MySQL?

I have a table with primary key 'Id' of varchar type. I want to select the next row when user clicks next record, in php, for example 1st row id= 'a' 2nd row id= 'b' 3rd row id='h' 4th row id='z' ...
-1
votes
2answers
54 views

MySQL Query can we count rows using php to reduce time of count(*) in a query or there is no difference?

Having the following queries, where the first query is returning a field of number of rows found, and the second returns the actual rows: First Query: SELECT count(*) as total FROM individual i ...
0
votes
1answer
27 views

Update two tables, each on separate MySQL servers, on two different machines in one query?

Have two MySQL servers running on two different machines in a local network. Using PHP and accessing via IP. No problems there. The databases have identical schemas. One was an import from the other ...
0
votes
2answers
30 views

Joining mysql tables

I am trying to join tables for a search form, and when I do the search exports the result x3 the output could you guys give me a hand please? $raw_results = mysqli_query($db,"SELECT * FROM ...
0
votes
2answers
83 views

Update from PHP 5 to PHP 7.0 - PHPmyAdmin will show two server logins: localhost / localhost:3306

I updated my Linux 14.04 LTS to 18.04 and had to downgrade the PHP 7.2 to 7.0 as I need to run some software which is not capable of the preinstalled PHP 7.2. I used PHP 5 so far. After I got ...
0
votes
2answers
32 views

Check if column UPDATE occurred

When we update a MySQL record with php, we can check if it has effect using: $mysqli->affected_rows; But how do I check which column has been modified? Example, in my table have the columns: id /...