Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
271 views
in Technique[技术] by (71.8m points)

php - Field is not inserting in Table

I have a sql but one thing is not inserting and that is the 'name' field (username)

My SQL code:

$serverdb->query("INSERT INTO cms_users
                (
                  name,lastvisit,online,ipaddress_last,newsletter,email_verified,
                  show_home,email_friendrequest,email_minimail,email,show_online)
                 VALUES    
                (
                 '".mysql_real_escape_string($row[1])."','".time()."','".time()."',
                 '".$_SERVER['REMOTE_ADDR']."','1','1','1','1','1','".mysql_real_escape_string($email)."','1')"
                 ) 
              or die (mysql_error()
    );

My website is not giving a error or something, its inserting this sql without a username. (btw, this is for a register page)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I am not sure that i have understood your problem very well but it seems that one of your problems is that you have mispelled the name attribute in your html form.

name="bean.name"

It should be

name="bean_name"

So $_POST['bean_name'] is always empty.

What is your code that fetches the row from your database?

Another issue is the use of mysql_* functions because they are deprecated (http://php.net/manual/en/migration55.deprecated.php). For security reasons try to use PDO or something similar.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...