if(isset($_POST['newname'])) { $nick=$_POST['nazv']; $new_name_theme=mysql_query("INSERT INTO `названия` (наименование) VALUES(`$nick`)")or die(mysql_error()); echo "account is added"; if($_POST['nazv']==false) { echo 'your account is not set'; } }
Closed due to the fact that off-topic participants Pavel Mayorov , aleksandr barakin , user194374, Denis , Alex 13 Dec '16 at 8:47 .
It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:
- "The question is caused by a problem that is no longer reproduced or typed . Although similar questions may be relevant on this site, solving this question is unlikely to help future visitors. You can usually avoid similar questions by writing and researching a minimum program to reproduce the problem before publishing the question. " - Pavel Mayorov, aleksandr barakin, Community Spirit, Denis, Alex
- Did you try to name the columns in English letters? And do you really get an error in this place? And some strange logic you have - first add a record from a variable, and then check the contents of this variable ... - BOPOH
- How do you advise to make a check: did the user input type = 'text' set the repeated name (value) or did he not fill it at all? - Stein_
- one1. It is not clear why you need $ _POST ['newname'], if it is not used in the code. Therefore, I will remove it. 2. If the user did not send the value (did not fill in the field), then isset ($ _ POST ['nazv']) == false; In addition, the user could pass spaces. Therefore, we additionally trim and check for emptiness. 3. Have you heard about SQL injection? It is better to read. --- Ie if roughly: if (isset ($ _ POST ['nazv']) && trim ($ _ POST ['nazv'])! = '') {// ... your actions echo "account is added"; } else {echo 'your account is not set'; } - BOPOH
|
2 answers
Can you send an exact request sent to the database?
Ideally, the syntax should be
INSERT INTO `test`.`tabname` (`param1`,`param2`,`param3`) VALUES ('val1','val2','val3')
Try setting table and field names in Latin letters.
- INSERT INTO
test
.названия
(наименование
) VALUES ('hypno-pub'); - Stein_ - oneideally, the syntax should be INSERT INTO ~ test ~. ~ tabname ~ (~ param1 ~, ~ param2 ~, ~ param3 ~) VALUES ('val1', 'val2', 'val3') Try setting the table and field names in Latin letters sadly, there is no possibility to add a slanting single quote (which is on the letter ё). I'll put a tilde instead ~ - Dima Bobrov
- Framed just such an option. It worked. but I do not understand why the original version does not work - Stein_
- There may be darkness, up to the wrong encoding of the file in which the query is formed. Or in the sql configs. I recommend you always use only Latin characters and always put the necessary quotes - Dima Bobrov
- I study independently because I took the topic of a diploma not in the direction of the specialty (in general there was no database and php), the head of the topic told me to make Russians understandable (I myself am ok (4th year head-student Guap) I'm a 4th year college student I’ve heard that everyone scold the Cyrillic in the code and in general ... a strange leader) - Stein_
|
"name" must also be in quotes. In addition, you have SQL injection.
- SQL injection? more detail please. what does it mean? - Stein_
|