Jump to content

Archived

This topic is now archived and is closed to further replies.

digitalgod

mysql table error

Recommended Posts

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
[code]
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'[/code]

here's part of the form
[code]
<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>[/code]

and here's my register.php

[code]
$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());
[/code]

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?

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
[!--quoteo(post=368901:date=Apr 26 2006, 01:01 PM:name=swatisonee)--][div class=\'quotetop\']QUOTE(swatisonee @ Apr 26 2006, 01:01 PM) [snapback]368901[/snapback][/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!

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.