Jump to content

Mysql insert or smth


Linjon

Recommended Posts

Hello. If i change player_id to 2 then player with id 2 gets points and if 3 then player with id 3 gets points. How can i do that dynamic (if player "user321" have id 5 and he send sms with his username then he get points) ?

 

<?php
$dbhost = 'localhost';
$dbuser = '********';
$dbpass = '********';
$dbname = '********;

mysql_connect("$dbhost", "$dbuser", "$dbpass") or die(mysql_error()); mysql_select_db("$dbname") or die(mysql_error());

$result = mysql_query("SELECT `player_id` FROM `w3_player` WHERE `player_name` ='".$_GET['message']."'") or die(mysql_error());
if(mysql_num_rows($result) != 1) {
echo " No user found" exit;
}else{

$addexp = 75000;

$id = mysql_query("SELECT `tablename` `player_id` FROM `w3_player` WHERE `player_name` ='".$_GET['message']."'");
mysql_query("UPDATE `database`.`w3_player_race` SET `race_exp` = `race_exp` + ".$addexp." WHERE `w3_player_race`.`player_id` = '1'' AND `w3_player_race`.`race_id` =1");
echo "Points added";
}
?>

Link to comment
https://forums.phpfreaks.com/topic/195992-mysql-insert-or-smth/
Share on other sites

Give us a little more info on this.  Answer the following questions..

 

1)  What is happening?

2)  What do you think SHOULD be happening?

3)  What error messages are you getting if any?

4)  Can you explain the situation a little bit more please?  I'm  a little unclear as to what you actually need.

 

All that you have here is an insert statement.  No one here is going to write code/functions for you.  We only help troubleshoot existing items/issues.  I'll come back and check on this tomorrow.  If the above 4 questions are not answered more code provided then I will just move on to help another poster whom put a little more time into his work.

1)  What is happening?

2)  What do you think SHOULD be happening?

3)  What error messages are you getting if any?

4)  Can you explain the situation a little bit more please?  I'm  a little unclear as to what you actually need.

Okei.

1) Nothing happening

2) Someone send SMS with his username and script will add points to user.

3) I dont get errors

4) I have `player_id` = '1' (thats player id for first user on database). I need make this script to automatic ( if second user on database send sms then he will get points.

 

I will reply if you have any questions.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.