mySql help.
#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


Messages In This Thread
mySql help. - by Chrham_2 - 05.08.2009, 16:27
Re: mySql help. - by clean180ollie - 05.08.2009, 17:11
Re: mySql help. - by Sergei - 05.08.2009, 17:14
Re: mySql help. - by Anarkien - 05.08.2009, 17:22
Re: mySql help. - by Chrham_2 - 05.08.2009, 17:31
Re: mySql help. - by Anarkien - 05.08.2009, 17:34
Re: mySql help. - by Chrham_2 - 05.08.2009, 21:42
Re: mySql help. - by Anarkien - 05.08.2009, 22:06

Forum Jump:


Users browsing this thread: 1 Guest(s)