1

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

Re: question about mysql

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

3

Re: question about mysql

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

4

Re: question about mysql

anybody? I still can't edit the registration code to insert another db query to insert values into another field

5 (edited by Utchin 2008-01-06 17:58)

Re: question about mysql

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

Sorry. Unactive due to personal life.

6

Re: question about mysql

matt1298 wrote:

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

7

Re: question about mysql

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

Re: question about mysql

that will get the id of the current user.. or what ever is in the [''].. that what you mean?

Sorry. Unactive due to personal life.

9

Re: question about mysql

http://punbb.org/docs/dev.html#integration

10 (edited by werny 2008-01-06 20:28)

Re: question about mysql

matt1298 wrote:

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?

11

Re: question about mysql

it will work if you have done the correct SELECT code..

Sorry. Unactive due to personal life.

12

Re: question about mysql

matt1298 wrote:

it will work if you have done the correct SELECT code..

so you are saying just create my own select quary for that table?

13

Re: question about mysql

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.

14

Re: question about mysql

ok thank, yeah ill just create a seperate query

15

Re: question about mysql

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

Re: question about mysql

You'll need to provide actual code or we can't help you wink

17

Re: question about mysql

Smartys wrote:

You'll need to provide actual code or we can't help you wink

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

Re: question about mysql

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.

19

Re: question about mysql

Smartys wrote:

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 smile , I so was so confused with the '\' in all the $db escape stuff