Topic: question about mysql
I am making a game, and I was wondering if I have a lot of fields should I add them all into the user table? or create a whole new table for them
You are not logged in. Please login or register.
PunBB Forums → PunBB 1.2 modifications, plugins and integrations → question about mysql
I am making a game, and I was wondering if I have a lot of fields should I add them all into the user table? or create a whole new table for them
It depends on what the fields are and how they are going to be used
Moved to Integration, since I assume you're talking about using PunBB as the basis for your game
yeah I think I am going to just create a different table, but I am looking at the registration for the db query to insert the values for registering, and I cant seem to create another quary to insert values into another table
anybody? I still can't edit the registration code to insert another db query to insert values into another field
open register.php and:
after line 200 =
// Add the user
$db->query('INSERT INTO '.$db->prefix.'users (username, group_id, password, email, email_setting, save_pass, timezone, language, style, registered, registration_ip, last_visit) VALUES(\''.$db->escape($username).'\', '.$intial_group_id.', \''.$password_hash.'\', \''.$email1.'\', '.$email_setting.', '.$save_pass.', '.$timezone.' , \''.$db->escape($language).'\', \''.$pun_config['o_default_style'].'\', '.$now.', \''.get_remote_address().'\', '.$now.')') or error('Unable to create user', __FILE__, __LINE__, $db->error());
$new_uid = $db->insert_id();
add
//START CUSTOM INSERT
$strSQL = ' INSERT INTO '.$db->prefix.'**TABLE*** (**CAT***, **CAT***) VALUES(**VALUE***, **VALUE***);';
$db->query($strSQL ) or error('Unable to add games ('.$strSQL.')', __FILE__, __LINE__, $db->error());
//END CUSTOM INSERT
and just edit the query to your needs
open register.php and:
after line 200 =
// Add the user $db->query('INSERT INTO '.$db->prefix.'users (username, group_id, password, email, email_setting, save_pass, timezone, language, style, registered, registration_ip, last_visit) VALUES(\''.$db->escape($username).'\', '.$intial_group_id.', \''.$password_hash.'\', \''.$email1.'\', '.$email_setting.', '.$save_pass.', '.$timezone.' , \''.$db->escape($language).'\', \''.$pun_config['o_default_style'].'\', '.$now.', \''.get_remote_address().'\', '.$now.')') or error('Unable to create user', __FILE__, __LINE__, $db->error()); $new_uid = $db->insert_id();
add
//START CUSTOM INSERT $strSQL = ' INSERT INTO '.$db->prefix.'**TABLE*** (**CAT***, **CAT***) VALUES(**VALUE***, **VALUE***);'; $db->query($strSQL ) or error('Unable to add games ('.$strSQL.')', __FILE__, __LINE__, $db->error()); //END CUSTOM INSERT
and just edit the query to your needs
thank, that what I was looking for
yes that worked, another quick question does any1 know where I would find where all the user sessions are stored like
$pun_user['g.id']
is found so I can add in new ones for my table
that will get the id of the current user.. or what ever is in the [''].. that what you mean?
that will get the id of the current user.. or what ever is in the [''].. that what you mean?
well I have a table called buildings, and I want to be able to put in
$pun_user['b.buildingname']
so I can use the different fields of that table
edit- do you see what I am trying to get at?
it will work if you have done the correct SELECT code..
it will work if you have done the correct SELECT code..
so you are saying just create my own select quary for that table?
Alter the two queries in include/functions which set the pun_user array to fetch the info from your table as well as the user table. Personally, I'd create a separate array and leave the pun_user array and db query as is, but the choice is yours.
ok thank, yeah ill just create a seperate query
arg I suck at trying to get the bd string escape to work, I am not quite sure how to fit it in for the query
//START CUSTOM INSERT
$strSQL = ' INSERT INTO '.$db->prefix.'**TABLE*** (**CAT***, **CAT***) VALUES(**VALUE***, **VALUE***);';
$db->query($strSQL ) or error('Unable to add games ('.$strSQL.')', __FILE__, __LINE__, $db->error());
//END CUSTOM INSERT
for the value, I can get the first one in for username, and I try to add the next value and bam! I get errors
You'll need to provide actual code or we can't help you
You'll need to provide actual code or we can't help you
ok, now I can tell if I am close or way off
//START CUSTOM INSERT
$strSQL = ' INSERT INTO '.$db->prefix.'Cities (username, cityname, leader) VALUES(\''.$db->escape($username).'\', \''.$db->escape($cityname).'\, \''.$db->escape($leader).'\'')
$db->query($strSQL ) or error('Unable to add games ('.$strSQL.')', __FILE__, __LINE__, $db->error());
//END CUSTOM INSERT
Try this:
//START CUSTOM INSERT
$strSQL = 'INSERT INTO '.$db->prefix.'Cities (username, cityname, leader) VALUES("'.$db->escape($username).'", "'.$db->escape($cityname).'", "'.$db->escape($leader).'")';
$db->query($strSQL ) or error('Unable to add games ('.$strSQL.')', __FILE__, __LINE__, $db->error());
//END CUSTOM INSERT
That should fix several issues with your code.
Try this:
//START CUSTOM INSERT $strSQL = 'INSERT INTO '.$db->prefix.'Cities (username, cityname, leader) VALUES("'.$db->escape($username).'", "'.$db->escape($cityname).'", "'.$db->escape($leader).'")'; $db->query($strSQL ) or error('Unable to add games ('.$strSQL.')', __FILE__, __LINE__, $db->error()); //END CUSTOM INSERT
That should fix several issues with your code.
oh man how can I thank you any more , I so was so confused with the '\' in all the $db escape stuff
PunBB Forums → PunBB 1.2 modifications, plugins and integrations → question about mysql
Powered by PunBB, supported by Informer Technologies, Inc.