mySql help.
#1

Fixed, I had stored the config
but forgot to make it check IP and Database.
Reply
#2

ask here

http://forum.sa-mp.com/index.php?topic=79352.0
Reply
#3

You need to indentify player, so mysql knows which player id it needs to update.
Reply
#4

Quote:
Originally Posted by Chrham_2
Hello.

I want to have a page where they can quit the job.
I made this:
Код:
<?php
require_once("config.php");
$sql = "UPDATE `samp`.`players` SET `Job` = \'0\' WHERE `players`.`id` = 1 LIMIT 1;";
?>
But it don't work.
Ok, a lot of things that can be wrong here I think.
First of all.. Why are you using `players`.`id`. And won't this only update "ID 1"'s job??
You should make your control panel so that the users can't be in-game while trying to edit their stats, like their job.

Rather do something like this:

Your in-game name is Che_Guevara.
You go to the UCP and write in Che_Guevera + your username in order to log in.
In the UCP you'll be able to change your job with a certain "job id".
job id 1 = farmer
job id 2 = police
etc..

Get the session ID from the login (which should be "Che_Guevara").
Like.. $_SESSION['user'], or whatever your session is called.
Eventually you can just do:
$username = $_POST['username'] in order to get the username (Che_Guevara) written from the database.
Then the $username will be a variable which holds the $_POST.

Now, when the user tries to update, is should be something like this:
Код:
<?php
require_once("config.php");
$sql = "UPDATE `samp`.`players` SET `Job` = \'0\' WHERE `player`.`name` = '$username' LIMIT 1;";
?>
Of course, I don't know if this will work at all..

And by the way, this script will make the job ID 0.
By replacing "0" with "$jobid" or something similar, you can allow the user to write the job ID themselves through a form.

I guess this became a pretty long post, and if you don't have any experience in MySQL, it might be a bit hard to understand what I mean.
Reply
#5

Quote:
Originally Posted by Anarkien
Quote:
Originally Posted by Chrham_2
Hello.

I want to have a page where they can quit the job.
I made this:
Код:
<?php
require_once("config.php");
$sql = "UPDATE `samp`.`players` SET `Job` = \'0\' WHERE `players`.`id` = 1 LIMIT 1;";
?>
But it don't work.
Ok, a lot of things that can be wrong here I think.
First of all.. Why are you using `players`.`id`. And won't this only update "ID 1"'s job??
You should make your control panel so that the users can't be in-game while trying to edit their stats, like their job.

Rather do something like this:

Your in-game name is Che_Guevara.
You go to the UCP and write in Che_Guevera + your username in order to log in.
In the UCP you'll be able to change your job with a certain "job id".
job id 1 = farmer
job id 2 = police
etc..

Get the session ID from the login (which should be "Che_Guevara").
Like.. $_SESSION['user'], or whatever your session is called.
Eventually you can just do:
$username = $_POST['username'] in order to get the username (Che_Guevara) written from the database.
Then the $username will be a variable which holds the $_POST.

Now, when the user tries to update, is should be something like this:
Код:
<?php
require_once("config.php");
$sql = "UPDATE `samp`.`players` SET `Job` = \'0\' WHERE `player`.`name` = '$username' LIMIT 1;";
?>
Of course, I don't know if this will work at all..

And by the way, this script will make the job ID 0.
By replacing "0" with "$jobid" or something similar, you can allow the user to write the job ID themselves through a form.

I guess this became a pretty long post, and if you don't have any experience in MySQL, it might be a bit hard to understand what I mean.
Yes, I knew that, but i was just suppodsed to set MY job to 0 and my ID was 1, and rest i would figure out my self, but i get errors that it denies connection.
Im sure i have it trying to conect my IP and right database, and username is right and i have blank password because i dont have password. But i get denied the connection to database.
Reply
#6

Are you hosting the website on localhost, or on a remote host (on the Internet)?
By the way, are you Norwegian?
Might be easier to help you then...
Reply
#7

Quote:
Originally Posted by Anarkien
Are you hosting the website on localhost, or on a remote host (on the Internet)?
By the way, are you Norwegian?
Might be easier to help you then...
Yes im norwegian, but i fixed it
Reply
#8

Quote:
Originally Posted by Chrham_2
Quote:
Originally Posted by Anarkien
Are you hosting the website on localhost, or on a remote host (on the Internet)?
By the way, are you Norwegian?
Might be easier to help you then...
Yes im norwegian, but i fixed it
Good to hear .
Ok, good!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)