Mysql database Error(need help bad)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

boondox
Forum Newbie
Posts: 20
Joined: Wed Oct 08, 2008 4:58 am

Mysql database Error(need help bad)

Post by boondox »

Ok I am running a game called Promisance on my home server..


Anyway Everytime I create an empire in the game it automatically places them into an un-named alliance..

I have checked and rechecked the code to see if the problem was there and I cannot find anything to indicate that there is a problem in the code...


Then I started going through the database tables..

I came across a problem in the Alliance Table..

For some reason there is a "space" in the feild that lists the name of the players alliance..

I have tried everything up to and including deleting and remaking that feild... However that "space" still remains..


If anyone can help me here I would appreciate it..
boondox
Forum Newbie
Posts: 20
Joined: Wed Oct 08, 2008 4:58 am

Re: Mysql database Error(need help bad)

Post by boondox »

no one has an answer for this one yet?
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Mysql database Error(need help bad)

Post by requinix »

...And you really expect us to know the answer?

Ask whoever made it.
boondox
Forum Newbie
Posts: 20
Joined: Wed Oct 08, 2008 4:58 am

Re: Mysql database Error(need help bad)

Post by boondox »

Unfortunately and very sad indeed Paul Purgett has passed away earlier this year..


And as I have had the misfortune of finding out Everyone else that does any coding on this particular game are very closed off..


There has been only 1 person that has helped me at all with this particular game and he is currently too busy with his school exams to be online when I am..


It is very unfortunate that with so many coders actually doing things to this game that none of them are at all helpful in anyway...
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: Mysql database Error(need help bad)

Post by onion2k »

Just edit the field name so there isn't a space.
boondox
Forum Newbie
Posts: 20
Joined: Wed Oct 08, 2008 4:58 am

Re: Mysql database Error(need help bad)

Post by boondox »

I lready tried that... I even deleted the whole table and made a new one yet that space remains.. I am completely baffled..
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: Mysql database Error(need help bad)

Post by onion2k »

boondox wrote:I lready tried that... I even deleted the whole table and made a new one yet that space remains.. I am completely baffled..
Post your "ALTER TABLE..." SQL statement that you're using to remove the space...
boondox
Forum Newbie
Posts: 20
Joined: Wed Oct 08, 2008 4:58 am

Re: Mysql database Error(need help bad)

Post by boondox »

not using an alter table statement just trying to do it in the database itself..
User avatar
Stryks
Forum Regular
Posts: 746
Joined: Wed Jan 14, 2004 5:06 pm

Re: Mysql database Error(need help bad)

Post by Stryks »

boondox wrote:For some reason there is a "space" in the feild that lists the name of the players alliance..
Soooo .... new players alliance has no value apart from a space? Or a space is present before the proper value?

A little clarification of the problem might greatly advance your chances of getting a useful response. What do you expect to happen? What makes you think that this space causes the problem if removing it has no effect? Do you get any actual errors, or just odd behavior? Do you have error reporting turned on to try and flush out errors? Can you post the table structure and some sample data, and perhaps some sample code around where the desired process fails?

Seriously, giving us too much info is more helpful than too little. I cant speak for anyone else, but for myself, I have no idea what this game is, how it works, or what the codebase looks like. You're going to have to hit the jackpot to find someone who knows enough about this particular game to be able to answer your questions off the top of their head from the description you give.

Help us out so that we can help you.

Cheers
boondox
Forum Newbie
Posts: 20
Joined: Wed Oct 08, 2008 4:58 am

Re: Mysql database Error(need help bad)

Post by boondox »

Ok the field is as follows..

Code: Select all

 
alliance  type=varchar(10) function=blank null=no
 
Now when you go to that feild in the database there is a Space in the Value field (this is where the clan name goes when they join a clan)
User avatar
Stryks
Forum Regular
Posts: 746
Joined: Wed Jan 14, 2004 5:06 pm

Re: Mysql database Error(need help bad)

Post by Stryks »

I guess what I mean is, given that null is not allowed, and a new user probably has no alliance, perhaps the original designer just inserted a space in order to leave the field blank, and (although not good practice) is actually not the problem?

I feel like we need a clearer idea of what is supposed to happen vs. what actually happens.
boondox
Forum Newbie
Posts: 20
Joined: Wed Oct 08, 2008 4:58 am

Re: Mysql database Error(need help bad)

Post by boondox »

Ok what is supposed to happen is the users/players alliance value is supposed to be completely empty upon signing up for the game...


Instead there is a "space" ie >>> <<<< space in the Alliance Value for every player that joins the game...


Meaning that for the players to be able to join or create clans I have to go into the database and enter a 0 for each and every players alliance value..
User avatar
Stryks
Forum Regular
Posts: 746
Joined: Wed Jan 14, 2004 5:06 pm

Re: Mysql database Error(need help bad)

Post by Stryks »

OK ... that helps somewhat.

But what I am trying to point out to you. The field type is varchar, meaning I'm expecting text or numbers, I don't really know. You could be referencing the primary key or some other textual value. I assumed that not being defined as integer, then textual content was norm. However, you specify that no null values are allowed. This means that at creation time, *something* needs to be set ... it cannot be NULL (blank in other words). Given this, I would imagine that adding a space at creation time might have seemed like a solution to the designer. If it was, then this may not be a problem as it may have been factored in later on.

However, you seem to imply that changing it to 0 is the desired action. You dont give any reason that this might be good, nor do you tell us if this actually fixes your problem.

If it does, then you need to look at the code that creates the row. Can you post that here? It might be specifying that space is set, or perhaps no value is passed and the field has a default value of a space. Running the query

Code: Select all

DESCRIBE your_table_name;
can help you verify the latter. Either way, changing the creation SQL to set it to 0 will work ... assuming that a setting of 0 works. And if an integer is used to represent the alliance, then you might as well change the column type to int(11) default=0 and let it take care of itself.

To clarify ...
boondox wrote:Ok what is supposed to happen is the users/players alliance value is supposed to be completely empty upon signing up for the game...
The column alliance CANNOT be NULL. You CANNOT leave it empty. For the row to be created, either a value must be passed when the row is being created, or a default value must be present. If you have recreated the table, I assume it's not the latter.

Go find the INSERT query near the end of the creation process and examine the SQL. Or better yet, post it back here. Odds are that either a space is being passed as the field value, or an unset or broken variable (containing a space) is being passed instead. Either way, the query will tel you more.

Hope this helps.
boondox
Forum Newbie
Posts: 20
Joined: Wed Oct 08, 2008 4:58 am

Re: Mysql database Error(need help bad)

Post by boondox »

Ok here is a dump of my table structure..

The Red Line is where I am having problems... The syntax works but the field ALWAYS has a space in it after the database is set up

Code: Select all

CREATE TABLE `players` (
  `username` varchar(10) NOT NULL default '',
  `password` varchar(200) NOT NULL default '',
  `email` varchar(40) default NULL,
  `state` varchar(10) default NULL,
  `name` varchar(20) default NULL,
  `empire` varchar(35) NOT NULL default 'Unnamed Realm',
  `race` varchar(8) NOT NULL default 'Past',
  `IP` varchar(15) default NULL,
  `lastday` int(11) default NULL,
  `infantry` bigint(21) default NULL,
  `cash` bigint(200) default NULL,
  `tanks` bigint(21) default NULL,
  `helis` bigint(21) default NULL,
  `turns` int(11) NOT NULL default '0',
  `land` int(11) NOT NULL default '100',
  `freeland` int(11) default NULL,
  `food` bigint(200) default NULL,
  `peasants` int(11) default NULL,
  `attacks` int(11) NOT NULL default '0',
  `spies` int(11) default NULL,
  `shops` int(11) default NULL,
  `homes` int(11) default NULL,
  `industry` int(11) default NULL,
  `barracks` int(11) default NULL,
  `labs` int(11) default NULL,
  `farms` int(11) default NULL,
  `turnsused` int(11) default NULL,
  `valcode` varchar(9) default NULL,
  `tax` int(11) default NULL,
  `validated` int(11) default NULL,
  `online` int(11) default NULL,
  `free` int(11) NOT NULL default '0',
  [color=#FF0000]`alliance` varchar(10) default '0',[/color]
  `savings` bigint(20) default NULL,
  `loan` bigint(20) default NULL,
  `runes` bigint(200) default NULL,
  `wizards` int(11) default NULL,
  `infind` int(11) default NULL,
  `tnkind` int(11) default NULL,
  `helind` int(11) default NULL,
  `spyind` int(11) default NULL,
  `networth` bigint(21) default NULL,
  `rank` int(11) NOT NULL default '0',
  `num` int(11) NOT NULL auto_increment,
  `shield` int(11) NOT NULL default '0',
  `gate` int(11) NOT NULL default '0',
  `defense` int(11) NOT NULL default '0',
  `cookie` varchar(48) default NULL,
  `multi` int(11) NOT NULL default '0',
  `messages` int(11) default NULL,
  `lasthour` bigint(200) NOT NULL default '0',
  `clear` int(11) NOT NULL default '0',
  `towers` int(11) default NULL,
  `forces` int(11) NOT NULL default '0',
  `vacation` int(11) NOT NULL default '0',
  `ticket` int(11) default NULL,
  `aid` tinyint(11) NOT NULL default '0',
  `offense` int(11) default NULL,
  `race2` varchar(20) NOT NULL default '',
  `signed` varchar(20) default NULL,
  `allytime` int(11) NOT NULL default '0',
  `ships` bigint(20) default NULL,
  `shpind` bigint(20) default NULL,
  `daysidle` int(11) NOT NULL default '0',
  `health` tinyint(4) NOT NULL default '100',
  `msgtext` text,
  `newstext` text,
  `pinfmkt` bigint(20) NOT NULL default '5000',
  `ptnkmkt` bigint(20) NOT NULL default '5000',
  `phelmkt` bigint(20) NOT NULL default '5000',
  `pshpmkt` bigint(20) NOT NULL default '5000',
  `pfodmkt` bigint(20) NOT NULL default '100000',
  `turnsstored` mediumint(3) NOT NULL default '0',
  `sig` text,
  PRIMARY KEY  (`num`),
  UNIQUE KEY `username` (`username`),
  KEY `password` (`password`),
  KEY `forces` (`forces`),
  KEY `race2` (`race2`),
  KEY `race` (`race`)
) ENGINE=MyISAM AUTO_INCREMENT=37 DEFAULT CHARSET=utf8 AUTO_INCREMENT=37 ;
User avatar
Stryks
Forum Regular
Posts: 746
Joined: Wed Jan 14, 2004 5:06 pm

Re: Mysql database Error(need help bad)

Post by Stryks »

Wow .. that's a hell of a table. 8)

OK. That tells us that a value must be being passed when each record is created, because if it weren't, the default value would be applied, in this case 0.

So, you're going to have to find the code in your PHP script where the account is created. Hard to tell you where that will be really, but start looking in form that you fill in to create an account, find the filename in for form tag's action property, and then open it up in your preferred PHP editor program.

For example, if you look at your account creation form, you'll find something like ...

Code: Select all

<form name="frm_create" action="createAccount.php">
If that was the case, you'd be opening would be createAccount.php. If it is the same filename as the form, then you'd look in there towards the top of the page.

Either way, you'd then hunt through it to find something along the lines of ...

Code: Select all

$sql= "INSERT INTO players .. something .. ";
Then post back that line, plus 10 or 15 lines before.
Post Reply