Questions tagged [mysqli]

1

votes
1

answer
253

Views

How fetch_assoc know that you want the next row from the table?

If we would have code like this: $result = $conn->query('SELECT username FROM users'); $row1 = $result->fetch_assoc(); echo $row1['username'], ''; $row2 = $result->fetch_assoc(); echo $row2['username'], ''; Second echo would show username from second row in table, but why? How fetch_assoc() know tha...
Remniscate
1

votes
4

answer
31

Views

PHP - Having trouble inserting dates from a date column with null values. Values are inside an array

I'm making a SQL Server to MySQL program that allows me to sync contents between two identical tables. However, I'm having trouble with inserting date values from a date column that has some of its cells set to NULL. The way this should work is that it should convert each value from the date column...
YMSmash
1

votes
2

answer
33

Views

Merge Rows based on unique ID in form of a JSON set in SQL

I have a table and I want to merge rows based on common ID ID file_id quantity 3 1122 25 3 1123 3 4 1126 7 4 1127 1 I want to get ID file_quantity_merged 3 {['file_id':1122, 'quantity': 25],['file_id':1123, 'quantity': 3]} 4 {...
Harry_pb
1

votes
2

answer
35

Views

I want to fetch data from a column on a database, average the data received, and echo the result

I have created a database called quizresults. Within it there are two columns; id and result. So far I have the code below; $average = 'SELECT result FROM quizresults;'; $averageresult = mysqli_query($conn, $average); $resultCheck = mysqli_num_rows($averageresult); if ($resultCheck > 0) { while ($ro...
HTML-Help
1

votes
1

answer
21

Views

Optimize Sql query. remove sub query from where clause

I want to optimize mysql query and want to remove sub query from where clause to reduce execution time I want to do this by JOIN but don't know how to use condition with respect to parent query. SELECT c.`id`, c.`first_name`, c.`last_name`, cs.`name` AS new_status, csd.`start_date` AS new_start_date...
Zohaib Hassan
1

votes
2

answer
1.4k

Views

MySQL Trigger Performance Degredation (To use or not to use)

So I've created this trigger: DELIMITER $$ CREATE TRIGGER `increment_daily_called_count` BEFORE UPDATE ON `list` FOR EACH ROW begin if (NEW.called_count != OLD.called_count) then set NEW.daily_called_count = OLD.daily_called_count(NEW.called_count-OLD.called_count); set NEW.modify_date = OLD.modify...
ajax1515
-1

votes
0

answer
16

Views

Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, bool given in [duplicate]

This question already has an answer here: mysql_fetch_array()/mysql_fetch_assoc()/mysql_fetch_row()/mysql_num_rows etc… expects parameter 1 to be resource or result 32 answers How to get MySQLi error information in different environments 1 answer Warning: mysqli_fetch_assoc() expects parameter 1...
Virat Virat
1

votes
1

answer
48

Views

Comparing input data with data queried from database

So when I tried to get one random row in database and store it into variables, it seems like I cannot reuse those variables for my next sql query as I was tried in these lines. First I get one random row in database and store it into variables for later use $mysqli = new mysqli($hostname, $username,...
Quang Huy
1

votes
1

answer
59

Views

how to fix timeout while creating a file scanner in php

Hello guys i am trying to a file scanner and add the data to be saved on the database the files are like 15,000 almost the scanner scans but just half of the directory the times up. My code looks like that
Chris Ngure
1

votes
1

answer
41

Views

MySQL Where Clause By Last String

i have a some data code like this : PR 00001J PR 00001B PR 00002B PR 00002J PR 00003J how i can get data only J with where clause ? is it need something like regex ? i've been try with this query but the output was NULL SELECT MAX(request_code) as max_request_code FROM `request` WHERE RIGHT('reque...
Not a Pwntester
1

votes
3

answer
51

Views

if a value is on mysqli database do not create a button on php

I have a database table like ----------------- | id | time | |----|----------| | 1 | 9am-10am | | 2 | 11am-12pm| and a PHP array $times= array('8am-9am','9am-10am','10am-11am','11am-12pm','12pm-1pm','1pm-2pm','2pm-3pm','3pm-4pm','4pm-5pm','5pm-6pm','6pm-7pm','7pm-8pm','8pm-9pm','9pm-10pm'); My...
Mondin A.
1

votes
3

answer
35

Views

How to select a value and then update a field

I have two tables, one that stores the the id of the an old img id | old_img_name | old_img_id and another table that stores the info of the current img id |img_name | img_w | img_h | etc.... and im trying to create a query to update(switch) the info from the old table into the new one, the only fie...
Pedro
1

votes
2

answer
38

Views

How do I automate this date code,s o that I don't have to change it every year. I need all dates greater than or equal to Dec of last year

How do I automate this date code,s o that I don't have to change it every year. I need all dates greater than or equal to Dec of last year. For example in 2019 i need dates of dec 2018 +. In 2020 I will need load dates of Dec 2019 + where (Load_Date) >= #12/01/2018#
user3860954
1

votes
4

answer
41

Views

Group data from table in PHP

I have a table sql like this post_id point user_id 5 1.0 1 6 1.5 1 7 0.0 2 8 1.5 3 9 1.0 3 ... I want to print the data into this ( group the posts by user_id ) user_id post_id(point) total point 1...
MCN
-1

votes
1

answer
15

Views

How to insert data into 2 database?

I am trying to insert data into 2 tables which are in different database. But I'm not able to connect to the second database. $con1 = mysqli_connect('localhost','root','','db1'); $sql_1 = 'insert into enquiry(name,email,phone,subject,message,service_category) values('aa','[email protected]','12344','xxx','d...
Ajay Viswanath
1

votes
0

answer
44

Views

how to display a pdf file as a download link from mysql without path directing way in php?

I tried to display pdf files from mysql in the webpage without any path directory. is it possible to do that? I tried this:
saisun7
1

votes
1

answer
85

Views

Insert into datetime field without duplicates in interval sql

i have table with tv shows, in this table there are columns, one for start time and one for finishing time. I need to make that if you want to insert tv show that you cannot put 2 tv shows in same time, like in real television, can you please help me to make this. Thanks. Table tvshows have columns:...
iposave
1

votes
1

answer
46

Views

how to keep the date unchanged when changing other data?

I want to update the status column in my table, but the date column of the message is also updated. How can I only update the status column only without the date field ? Data type: Status => Varchar messgae_date => Timestamp Query : 'UPDATE mytable SET status='1' WHERE status='0'' Thank's before ..
Aditya
1

votes
2

answer
233

Views

Trying to get MySQL results to display horizontally

I'm creating a webpage that lists ten characters in a game based on their experience levels and displays them with a picture associated each character. My code works, but the output is in a column when I'd like it to be in a row. I did see where something very similar had been asked here: MySQL data...
Pomegranate
1

votes
0

answer
56

Views

RESTFUL API delete design using mysql

I suppose the standard delete API would be like this DELETE example.com/student/:id But I'm confused with mysql. I have 2 tables, one is students, one is subjects. The tables look like this students - id (FK) - name subjects - student_id (PK) - math - english so how would I build my REST API? I hav...
Globin Hughes
1

votes
3

answer
42

Views

insert error to database from a for loop

I tried inserting some license generated kes from a for loop into the database but I was getting Errormessage: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'keys)values('46F2-SH73-2QDD-Z4VH-HV')' at line 1 I ha...
Tonye Boro
1

votes
2

answer
49

Views

PHP - Unable to update MySQL Table

I'm trying to create email verification but for some reason, I can't update my MySQL table. I've tried various different ways of doing it but I can't seem to get it to update.
Oscar Downing
1

votes
0

answer
263

Views

DataTables warning: table id=table_companies - Invalid JSON response. For more information about this error, please see http://datatables.net/tn/1

Please help me. I am having a bug here i dont know why everytime i refreshes the page it alerts the error, DataTables warning: table id=table_companies - Invalid JSON response. For more information about this error, please see http://datatables.net/tn/1 help me with this. i dont know what ill do ne...
Onepaul Dimaliwat
1

votes
0

answer
54

Views

Mapping table over multiple values sql php

At first i had 2 table: Room is a table which store the room and their type. Reservation is a table where users make their booking. Room (roomnumber, roomtype, price) Reservation (reservationid,roomnumber, checkin, checkout) reservationid can have multiple values of roomnumber(for e.g, 100,101,102,....
mohamm
1

votes
1

answer
40

Views

Display Dropdown in HTML with PHP

I am android developer and making one admin panel for one of my android application. I know very basic PHP. currently I am displaying input field with value and user can change with text input and can save value with submit button. Its like below Admob On/off :-
Meena Parmar
1

votes
3

answer
46

Views

MySqli Query result row

I want use one column value in mysqli query but I am not able to find way of use it. My query is like this $result = mysqli_query($mysqli,'SELECT * FROM tbl_settings'); while($row = $result->fetch_assoc()){ if($row['automatic'] ==on){ $number= '$result['automatic']'; echo $number; $sql = mysqli_quer...
Meena Parmar
1

votes
0

answer
37

Views

Weighted Randoms

I've have a database of items which has a field called 'weight'. I have a script which picks an determined number amount of items (set by me) from the database and order by rand()/weight. I determine the weight based on it's value/worth something like if($value $weight ); } elseif($value >= 201000...
KmanOfficial
1

votes
1

answer
21

Views

Find Relevent Result Even it have Long Value Sql

Let Supppose I Have String in database Indian Apple(Kashmir) 30Kg at 3400 Now i wants to get data relevent to Indian Apple(Kashmir) So How Can i get ? For that i tried SELECT * FROM product where id='1' && name LIKE '%Indian Apple(Kashmir) 30Kg at 3400' But it does not give me proper result So How c...
1

votes
2

answer
2k

Views

edit and update data with ajax jquery

please help me. what wrong with my code . i want to use ajax to retrieve data from editable (form) to update and save on database , but it's doesn't work as well, here is my code : '>edit and edit function with ajax : $(document).on('click', '.edit' ,function() { var id = this.id; var split_id =...
青木 Japan
1

votes
0

answer
2.2k

Views

Can't create mysqli connection to MariaDB via PHP [duplicate]

This question already has an answer here: PHP parse/syntax errors; and how to solve them? 16 answers Reference - What does this error mean in PHP? 32 answers PHP's white screen of death 15 answers I have a new MariaDB 10.2 instance running on Windows 2012r2 with IIS 7 and PHP 7.1 (all on one mach...
Chip
1

votes
1

answer
37

Views

mysql update multiple tables, table 1 updates ok table 2 changes all values and ids

I am working on a simple DB and while I am a NOOB I have an update string where table 'employee' updates properly, table 'job' changes all values to the same except primary key. UPDATE employee,job SET employee.name='name', employee.vorname='vorname', employee.strasse='strasse' , employee.haus_nr='...
Frank Casser
1

votes
0

answer
15

Views

Create session from button name which is $row?

What I'm trying to do, I don't even know if it's possible. I'm loading up a database table that will have a button next to each row. That button has an ID and Name that is equal to my row's id. echo '$row->id'; Now, I want a session to be created with that id number so I figured I'd input this code...
Picmount Media
1

votes
1

answer
81

Views

Creating an array inside of an array for json using PHP

I am trying to replicate this json file using PHP but I cannot seem to get the array for object 'location' within another array called 'levels' 'levels': [ { 'id': 'lower', 'title': 'Floor 26', 'map': 'images/apartment/upper.jpg', 'minimap': 'images/apartment/upper-small.png', 'locations': [ { 'id':...
Dennis Hong
1

votes
0

answer
24

Views

sqlfiddle & MySQL, not the same result with @variable

I try to figure out why MySQL doesn't get the same result than sqlfiddle, can someone help me to solve my request? TABLE CREATE TABLE `test` ( `id` int(11) UNIQUE, `name` varchar(20), `time` int(11), `points` int(11), `car` varchar(10), `date`date ); INSERT INTO `test` (`id`, `name`, `time`, `points...
Nico68
1

votes
1

answer
24

Views

How to make a sql command with a php while loop in it

I want to make a sql while loop. The idea: $command = SELECT fr_id from fr WHERE GB_ID = $ID; $row = MYSQLI_FETCH_ARRAY($command); With that info i want to make an while loop $command2 = SELECT * FROM br WHERE GB_ID = while (results are comming) { $ row[FR_ID]; } Some of you know this wont work like...
rikkamp
1

votes
2

answer
186

Views

mysqli_multi_query: need to check single result?

I'm using this code to insert a record with a unique id and then return the id-string just created: $sql ='set @id=UUID();'; $sql .='INSERT INTO `items` (`id`,`parent`, `text`, `type`) VALUES(@id,''.$parent.'', ''.$text.'', ''.$type.'');'; $sql .='select @id;'; if (mysqli_multi_query($conn, $sql)) {...
Gwen Hufschmid
1

votes
4

answer
31

Views

mysql: user profile image is not saving in database,

A.o.A i working on user profile page and when i upload pic its not saving in database and not showing in browser,,, only saving in uploads folder
Umar
1

votes
1

answer
77

Views

Error from ReflectionClass:InvokeArgs

I have the following code which was working until recently but is now giving an error. (I suspect my website host may have moved me to a new server or upgraded something without letting me know - again!) function SqlPrepareAndExecute() { global $mysqli; // get the function parameters $args=func_get_...
Phil Preen
1

votes
1

answer
64

Views

Uploading and showing profile picture

I am trying to upload a profile picture to my social account but I am having a couple of problems . I want the name of the image to be unique so I decided to add the date and time to each of the pictures to prevent any confusion with the files . In my database I have name:date_time type:datetime le...
New indie
1

votes
0

answer
142

Views

Not setting to PAP freeradius - daloradius

I currently have a server with freeradius version 2.2.8 integrated with daloradius 0.9-9. When I try to connect with any user added in daloradius I get the following error: [pap] WARNING: Auth-Type already set. Not setting to PAP ++[pap] returns noop I wanted to know if you could give me give me ab...
Andrea

View additional questions