Jump to content


Photo

Unknown column 'mb5_password' in 'field list'


  • Please log in to reply
3 replies to this topic

#1 alabaster_lynch

alabaster_lynch
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 08 January 2006 - 05:31 PM

OK, here goes everytime I run this script, I always get

Unknown column 'mb5_password' in 'field list'

Here is the insert statement

$q = "INSERT INTO db_cam_protect (mb5_id, mb5_username, mb5_password, mb5_email, mb5_start_date, mb5_end_date, unixtime_end, mb5_payed, mb5_months, mb5_paytype, mb5_currency, mb5_confirm, mb5_active) values ('".$mb5_id."', '".$mb5_username."', '".$mb5_password."','".$mb5_email."','".$mb5_start_date."','".$mb5_end_date."','".$unixtime_end."','".$mb5_payed."','".$mb5_months."','".$mb5_pay_type."','".$mb5_currency."','0','0')";
        mysql_query($q) or die(mysql_error());

Now the particular field in question is produced by a simple random number generator
$mb5_password = substr(ereg_replace("[^0-9]", "", crypt(time())) .
        ereg_replace("[^0-9]", "", crypt(time())) .
        ereg_replace("[^0-9]", "", crypt(time())),0, 8);
        srand(time());

Now the database table looks like this
CREATE TABLE `db_cam_protect` (
  `mb5_id` varchar(20) NOT NULL default '',
  `mb5_username` varchar(60) NOT NULL default '',
  `mb5_password` int(11) NOT NULL default '0',
  `mb5_email` varchar(255) NOT NULL default '',
  `mb5_start_date` varchar(10) NOT NULL default '',
  `mb5_end_date` varchar(10) NOT NULL default '',
  `unixtime_end` varchar(20) NOT NULL default '',
  `mb5_payed` int(10) NOT NULL default '0',
  `mb5_months` int(3) NOT NULL default '0',
  `mb5_paytype` varchar(255) NOT NULL default '',
  `mb5_currency` varchar(255) NOT NULL default '',
  `mb5_confirm` int(3) NOT NULL default '0',
  `mb5_active` int(3) NOT NULL default '0',
  `mb5_logins` int(11) NOT NULL default '0',
  `mb5_expirationtime` varchar(20) NOT NULL default '',
  UNIQUE KEY `mb5_id` (`mb5_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

If you see something I don't, PLEASE let me know...thank you

#2 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 08 January 2006 - 07:55 PM

I have good news and bad news.

The good news is there's nothing wrong with the INSERT statement that you've posted, or your table design.

The bad news is that there's another SQL statement somewhere in your script that _is_ causing this problem. When you use die() as a result of an error, you do what LazyJones always suggests:

$result = mysql_query($sql) or die ("ERROR: ".mysql_error()." with query: $sql");

I'll bet it's not the statement that you think it is -- in fact, it could easily be a SELECT statement too!

Happy debugging.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#3 alabaster_lynch

alabaster_lynch
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 08 January 2006 - 10:25 PM

[!--quoteo(post=334591:date=Jan 8 2006, 01:55 PM:name=fenway)--][div class=\'quotetop\']QUOTE(fenway @ Jan 8 2006, 01:55 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
I have good news and bad news.

The good news is there's nothing wrong with the INSERT statement that you've posted, or your table design.

The bad news is that there's another SQL statement somewhere in your script that _is_ causing this problem. When you use die() as a result of an error, you do what LazyJones always suggests:

$result = mysql_query($sql) or die ("ERROR: ".mysql_error()." with query: $sql");

I'll bet it's not the statement that you think it is -- in fact, it could easily be a SELECT statement too!

Happy debugging.
[/quote]

When I set it up as suggested, it said that the posted query was the problem

#4 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 09 January 2006 - 12:50 AM

I have to believe you, but if I create the table you described, and test an INSERT with the specified columns, there's no problem at all. So something's amiss.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users