AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Once again mysql :D (https://forums.alliedmods.net/showthread.php?t=5803)

hellraser 09-13-2004 11:35

Once again mysql :D
 
heyyy all,so i've been looking around for some hours now and can't find a reason why this doesn't work.
What i wanna do is create a new line in a table when a player connects:
Code:

public client_connect(id){
  new host[64],user[32],pass[32],db[32],error[128]
  get_cvar_string("amx_mysql_host",host,63)
  get_cvar_string("amx_mysql_user",user,31)
  get_cvar_string("amx_mysql_pass",pass,31)
  get_cvar_string("amx_mysql_db",db,31)

  new name[32]
  new net_address[33]
  new query[1024]

  get_user_name(id,name,32)
  get_cvar_string("net_address",net_address,31) 

  new mysql = mysql_connect(host,user,pass,db,error,127) 
  if(mysql>1) {
  format(query,1024,"INSERT INTO player_info set server_id='%s',name='%s'",net_address,name)
  mysql_query(mysql,query)
  }else{
      server_print("Error")
  }
}

This works.

Then i want to update the table with the player infos:
Code:

public update_player_info(){

  new players[32]
  //new team[16]
  new name[32]
  //new status
  //new frags
  //new deaths
  new ping
  new loss
  new i
  new inum
  new authid[32]
  new net_address[33]
     
  // set player info
  get_players(players,inum)
  for(i = 0 ;i < inum; ++i){
    get_user_name(players[i],name,32)
    get_user_authid(players[i],authid,31) 
    //status = is_user_alive(players[i])
    //frags = get_user_frags(players[i])
    //deaths = get_user_deaths(players[i])
    get_user_ping(players[i], ping, loss)
    //get_user_team(players[i], team, 16 )
    get_cvar_string("net_address",net_address,31) 
   
    new query_b[1024] 
    format(query_b,1024,"UPDATE player_info server_id='%s',authid='%s' WHERE name='%s'",net_address,authid,name)
    mysql_query(mysql,query_b)   
  }
 
  return PLUGIN_CONTINUE
}

And for a strange reason the update doesnt work....

Please help!
Thanks

BAILOPAN 09-13-2004 12:10

you got them backwards

INSERT INTO table VALUES ( [ .. ] )

UPDATE table SET [ .. ] WHERE [ .. ]

hellraser 09-13-2004 12:19

nop thats not it... set is needed when you use INSERT INTO :(

EDIT: a part of what u said was right,sorry & thx i fixed it ;)


All times are GMT -4. The time now is 17:13.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.