Jump to content
MakeWebGames

Recommended Posts

Posted

Hey MWG community i was just working on my register.php & started wondering would it be possible to substitute that super long query in register.php by just setting default values for all those columns. for example instead of using

$db->query("INSERT INTO userstats VALUES($i, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10)");

couldnt i just set the default value for all those as 10 then remove the query? if so i would do this to all the queries :cool: except ones like userid, name, & password.

Posted

You could but you'd still have to have a Query there.. That being:

$db->query('INSERT INTO `usersats` (`userid`) VALUES('.$i.')');

p.s. I haven't coded in a few months + I am tired so this may not work. (I haven't tested it either)

Posted

While you stlll need to run that query, as it is now. There are other options where you do not need to do that, like triggers and such, but I'm not sure how far all webhosts support that with mysql.. It is a lot easier, as you can see by yourself, by just typing "VALUES ( $i )" instead of typing every value. With using defaults you'll have a much smaller chance on making a mistake or forgetting a value. Some people also like to give a bonus during user registration to a certain value, be sure to add that value to the code, because if you don't, it will just use the default value if there is any set for that field.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...