D
D
dk-web2015-08-03 17:52:08
PHP
dk-web, 2015-08-03 17:52:08

Can you comment on such a set of php functions?

Learning the world of web programming in php - I invent another bicycle for myself.
I'm doing a little functionality for the form handler...
Posted here:
ideone.com/oRRaAy
I would appreciate your comments.
The questions are as follows...

UPDATE cities2 SET `id`='7', `city`='Иваново' WHERE `id` = 7
Запрос выполнен успешно

Can't succeed because id=7 doesn't exist...
Everything else works... but I'd like to simplify it a bit.
I don’t know how to program in OOP yet ...
P.s. I switch from mysql to mysqli, but on the server this code is basically working

Answer the question

In order to leave comments, you need to log in

4 answer(s)
D
Dmitry, 2015-08-03
@thewind

Can't succeed because id=7 doesn't exist...

so what? This query does not raise an error because it is 1) syntactically correct; 2) does not contradict the principles of mysql

D
Dmitry Kovalsky, 2015-08-03
@dmitryKovalskiy

The request is correct. The fact that there were no fields to put down new values ​​means nothing. Believe it or not, there are also deletion requests that do not delete anything.
UPD: You have more sins in the code at the link. Concatenation of sql queries, flickering markup elements and echo (apparently a mess of working with the database and working with the client view).

E
entermix, 2015-08-03
@entermix

Use PDO to work with the database

O
Oleg, 2015-08-04
@ollisso

if you want to check "did the request change something" - you can just check affected_rows.
True, if you perform the same update twice as in your example, then the second time it will report that 0 lines have been changed .. because there is nothing to change.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question