Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

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

1 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...