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
vote
0answers
15 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 ...
-1
votes
0answers
13 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
13 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
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
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
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
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
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 ...
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 ...
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
18 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
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 ...
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
63 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
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)...
-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 ...
-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
75 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
32 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
17 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
55 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
31 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
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
1answer
41 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
30 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
209 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
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
408 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
98 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
58 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
28 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
16 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
20 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
76 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
116 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
66 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
35 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
42 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
245 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
7 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
53 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
46 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 ...