Jump to content


Photo

mysql table error


  • Please log in to reply
2 replies to this topic

#1 digitalgod

digitalgod
  • Members
  • PipPipPip
  • Advanced Member
  • 374 posts

Posted 26 April 2006 - 05:53 AM

Hey guys,

I have a form with a few drop down lists that collect info from a user and inserts it into a database. My problem is that it keeps telling me that a column doesn't exist when it does....

here's the table
id INT NOT NULL AUTO_INCREMENT,
  PRIMARY KEY(id),
  username VARCHAR(250),
  password VARCHAR(32),
  email VARCHAR(250),
  realname VARCHAR(250),
  code VARCHAR(32),
  active VARCHAR(3),
  country VARCHAR(50), 
  state VARCHAR(50),
  city VARCHAR(50),
  date_birth DATE not null,
  gender VARCHAR(6),
  mobile VARCHAR(10),
  carrier VARCHAR(15),
  race VARCHAR(50),
  language VARCHAR(50),
  timeoffset text NOT NULL,
  count int(10) NOT NULL default '0',
  emailnot text NOT NULL,
  nots text NOT NULL,
  inmemlist text NOT NULL,
  showmail text NOT NULL,
  timestamp int(10) NOT NULL default '0',
  last_login datetime NOT NULL default '0000-00-00 00:00:00'

here's part of the form
<td>*Country:</td>
  <td>
<select id='countrySelect' name='country' onchange='populateState()'>
        </select></td>
</tr>
<tr>
  <td>*State/Province:</td>
  <td><select id='stateSelect' name='state' disabled=true onchange='populateCity()'>
        </select>        </td>
</tr>
<tr>
  <td>*City:</td>
  <td><select id='citySelect' name='city' disabled=true>
        </select>
        <script type="text/javascript">initCountry('CA'); </script></td>
</tr>

and here's my register.php

$uname=$_POST['uname'];
    $pword=$_POST['pword'];
    $encrypt_pass=md5($pword);
    $c_pword=$_POST['c_pword'];
    $email=$_POST['email'];
    $c_email=$_POST['c_email'];
    $realname=$_POST['name'];
    $country=$_POST['country'];
    $state=$_POST['state'];
    $city=$_POST['city'];
    $month=$_POST['month'];
    $day=$_POST['day'];
    $year=$_POST['year'];
    $birth = $year + $month + $day;
    $gender=$_POST['gender'];
    $mobile=$_POST['mobile'];
    $carrier=$_POST['carrier'];
    $rand_a=rand(500,500000);
    $rand_b=rand(1,1000000);
    $code=substr(md5(rand(-$rand_a,$rand_b)),0,8);
mysql_query("INSERT INTO ".$prefix."users(username,password,email,realname,code,active,country,state,city,date_birth,gender,mobile,carrier) 
              VALUES('$uname','$encrypt_pass','$email','$realname','$code','no','$country','$state','$city','$birth','$gender','$mobile','$carrier')") or die(query_error());

and it keeps giving me this error whenever I submit the form
Unknown column 'country' in 'field list'

any ideas why it's doing that?

#2 swatisonee

swatisonee
  • Members
  • PipPipPip
  • Advanced Member
  • 253 posts

Posted 26 April 2006 - 05:01 PM


Is your table name
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]
".$prefix."users[/quote] or just users ? And if not, then you need to match a field for $prefix.


Shishya

#3 digitalgod

digitalgod
  • Members
  • PipPipPip
  • Advanced Member
  • 374 posts

Posted 26 April 2006 - 07:11 PM

[!--quoteo(post=368901:date=Apr 26 2006, 01:01 PM:name=swatisonee)--][div class=\'quotetop\']QUOTE(swatisonee @ Apr 26 2006, 01:01 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Is your table name
or just users ? And if not, then you need to match a field for $prefix.
[/quote]

yeah I found the mistake and it was pretty dumb on my part, $prefix is assigned in my config.php and I accidently replaced the one on my server with an old config.php so it had the wrong variable but the table still existed so I didn't realise that it was trying to write on a different table....

can't believe I lost a few hours on this....

thanks!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users