User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 373,104 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,650 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting

Problem with INSERT command into MySQL

Join Date: Dec 2007
Posts: 42
Reputation: justted is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
justted justted is offline Offline
Light Poster

Problem with INSERT command into MySQL

  #1  
Mar 27th, 2008
Hello everyone,

I seem to be having a problem inserting some information into a MySQL table. Below is a copy of the MySQL table code I used and also the PHP code. I was wondering if anyone can help me find out why it wont insert the information.

What I am trying to do is make it so members can go and choose an option to join one of a selection of islands which will be subdivded into towns and then the town subdivided into villages. Each of the island/town and village levels will have a staff rank to allow certain members to have access rights to those pages.

But basically as you can see I want to set the default island/town/village levels and ranks to 0 intially. Then when the member goes to the island -age they will choose an island of say 4 options (which would update the island field to between 1-4 to depending on selecting an option. Then they choose a town of say between 1-4 and then again it updates the town field of between 1-4. And again for the village.

However, for some reason this code isnt working so far and its stopped me in my tracks. lol

I am using the $userid and $game tags which are apart of the include global.inc.php page I believe. I need this to identify the user and their individual details.


Can anyone help or see any obvious mistakes?


Here is the MySQL code:

CREATE TABLE `island2` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `user` int(11) NOT NULL default '0',
  `island` int(11) NOT NULL default '0',
  `town` int(11) NOT NULL default '0',
    `village` int(11) NOT NULL default '0',
      `islandrank` int(11) NOT NULL default '0',
    `townrank` int(11) NOT NULL default '0',
      `villagerank` int(11) NOT NULL default '0',
  `game` int(11) NOT NULL default '0',
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=6359 ;


And this is the PHP island1090.pro.php page which should once the link on island1090.php is clicked insert a row. But currently it doesnt do it.
<?php

/*

Move to Island 1090 (island1090.pro.php)

*/
ob_start();
$rank_check = 1;
include "global.inc.php";


$check = fetch("SELECT * FROM island2 WHERE user = '$userid' AND game = '$game'");
if ($check[id])
{
	die(header(error("isaland1090.php?game=$game","You already have a House.")));
}


mysql_query("INSERT INTO island2 (id,user,island,town,village,islandrank,townrank,villagerank,game) VALUES ('',$userid','1','1','1','0','0','0','$game')");
header(error("island1090.php?game=$game","You have just settled into *****Island name here*******."));

?>


Any help is much appreciated.


Thank you

Justin
AddThis Social Bookmark Button
Reply With Quote  
All times are GMT -4. The time now is 5:17 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC