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
0 votes
1 answer
1k 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
0 answers
118 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
2 answers
7k views

How can one drop all default values and allow NULL for all columns of a table?

I'm working on a PHP script to modify the primary key (PK) of a table. My current code is: $q = "SHOW KEYS FROM $db.$table WHERE Key_name='PRIMARY';"; $keys = Query ( $q); if ( $keys) { $q = "...
2 votes
1 answer
3k 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
1 answer
4k 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,
0 votes
1 answer
207 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
0 answers
1k 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
1 answer
31 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 ...
1 vote
2 answers
199 views

professional services (consultants) resource allocation system

I am developing a resource allocation system using PHP and mysql. I have consultants and projects and I need to allocate the consultants on to various projects for various periods of time on various ...
0 votes
1 answer
153 views

Searching through ~1M slow [closed]

I've never had a database with this many rows, so I can new to keeping the search time to a minimum. I have a database table with 1.5M rows. The primary key is an auto-increment id. Then there is ...
2 votes
0 answers
1k 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 ...
1 vote
0 answers
129 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
1 answer
97 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
0 answers
424 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
0 answers
1k 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
2 answers
84 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
1 answer
238 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
0 answers
214 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
3 answers
40 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
1 answer
44 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 ...
1 vote
1 answer
736 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 ...
1 vote
1 answer
4k views

PHP MYSQL Update Two Tables Using Cross Joins

I am running into a problem updating my two tables at the same time. My first table res which needs to be updated every time the other table rest gets input from a HTML Form. Table res=> http://...
0 votes
2 answers
3k 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
1 answer
101 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
1 answer
223 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
2 answers
1k 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
0 answers
495 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(...
2 votes
1 answer
25k views

PhpMyAdmin Import Error-MySQL server has gone away/Unrecognized Keyword

So I've exported a MySQL database from PHPMyAdmin (which I access from within IIS Express on a Windows 8 machine) and I'm trying to import this database onto another machine, however on that machine I ...
8 votes
2 answers
1k 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
2 answers
1k 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
2 answers
451 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
2 answers
3k 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 /...
0 votes
1 answer
5k views

In PHP MySQL how to sum or not sum multiple columns?

I have three tables this is my codes: <table border='1'> <tr> <th>Subject</th> <th>Mark1</th> <th>Mark2</th> &...
0 votes
2 answers
439 views

How to select datas for a particular user between a date range

I am querying a table with where condition in which i want to choose between a particular date range at present my query is like this with a where condition. WHERE entered_by = '1' AND date_created = ...
0 votes
2 answers
1k views

phpmyadmin/ mysql how to copy a table with all its constraints

I tried to copy a table which is connected to another table through a foreign key using $query = "CREATE TABLE table1 AS SELECT * FROM table 2"; but when I run this query it copies every thing but ...
3 votes
2 answers
5k views

Preventing mysql deadlocks in your php application that uses SELECT… LOCK IN SHARE MODE

If I understand SELECT ... LOCK IN SHARE MODE correctly, you can place it into a mysql transaction to select the rows you will be working with during that transaction. This is done in order to "lock ...
0 votes
2 answers
86 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 ...
1 vote
3 answers
5k views

How to determine if a column already exists in a MySQL table before altering the table to add it?

I am trying to determine if a column already exists in a MySQL table before altering the table to add it. I need an all in one query I can run since I am executing this through an old PHP mysql ...
0 votes
2 answers
491 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 ...
6 votes
2 answers
12k views

Escaping T-SQL Keywords

$sql = "SELECT Kill FROM tbl_pvporderview"; Problem is that I end up with: Incorrect syntax near the keyword 'Kill'. Because kill is a T-SQL command... any way to bypass it? I can't change the ...
1 vote
3 answers
55 views

Quering date from date and time field

I have a table which is like this. CREATE TABLE `candidate` ( `candidate_id` int(11) NOT NULL, `site_id` int(11) NOT NULL DEFAULT '0', `last_name` varchar(64) COLLATE utf8_unicode_ci NOT NULL ...
0 votes
1 answer
56 views

How to write a query for picking 20 items from six tables with two conditions

I have six tables. candidate,candidate_joborder,company,extra_field,joborder,user I want to pick up 20 items from these tables with query those items are as follows. name from company table. title,...
0 votes
1 answer
957 views

Query Error: Error: ER_NON_UNIQ_ERROR: Column 'candidate_id' in field list is ambiguous

This is my query SELECT user_name,candidate_id FROM user AS usr INNER JOIN candidate as can ON usr.user_id = can.entered_by INNER JOIN candidate_joborder as canjo ON can.candidate_id = canjo....
0 votes
1 answer
32 views

Converting colums as row

My mysql data is like this CREATE TABLE `extra_field` ( `extra_field_id` int(11) NOT NULL, `data_item_id` int(11) DEFAULT '0', `field_name` varchar(255) DEFAULT NULL, `value` text, `...
2 votes
1 answer
2k views

How to select multiple item from database

Please help me. How to select student result from databese using multiple select. But not work....... My Student Database like - std_profile id StudentId stdName stdRoll stdClass 1 ...
1 vote
1 answer
59 views

extract different number of rows from multiple tables

I have a quick question. I'm looking for the concept behind this, not necessarily a ready-to-use code, but if it's not too complex, I don't mind a quick solution. I have an app that manages accounts. ...
1 vote
1 answer
893 views

Take 1 row of data from MySQL and Split the Results into a Table

I have a mysql database that looks like this: proj_id | job1_name | job1_type | job1_time | job2_name | job2_type | job2_time | ... --------+-----------+-----------+-----------+-----------+-----------...
2 votes
1 answer
782 views

How to open a file in MySQL event scheduler?

I am currently creating my first event in MySQL: CREATE EVENT check_for_uploads ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 MINUTE ON COMPLETION PRESERVE DO // I would like to open a .php file ...
3 votes
1 answer
584 views

PHP / MYSQL connection failures via socket under moderate load [closed]

I've done quite a bit of reading before asking this, so let me preface by saying I am not running out of connections, or memory, or cpu, and from what I can tell, I am not running out of file ...
3 votes
1 answer
1k views

Different types of users in one table, How to add data off different users

I have 5 type of users: Super Admin Coordinator Supervisor Student External Examiner All of them have some common attributes like ID, name, email etc. I have inserted them in one table user ...

1
3 4
5
6 7
14