Query error - very wired
Posted: Sat Mar 03, 2007 10:40 pm
This is so wired, hope someone can help me:
This is the problem part:
And when I fill in the form and hit submit button and echo $insert I get this:
Clearly a record was added as mysql_affected_rows() returns 1
and to make more sense, when the page is refreshed it says, the username exist please take a different name to show that this query worked just fine.
But when I go the database I see nothing there, and even from admin panel where the buyer details goes for approval it does not appear there either.
I thought something could be wrong with my insert statement (even though I was 100% sure there cant be as it returned 1) I copied the insert statement (I echoed it remember) and then open phpmyadmin, run that exact same query and only then it inserts a record and only then from admin panel you can see a new buyer joining is subject to approval.
Here is my database table :
If anybody is interested to run this code on their own server I can give you the full code.
Please help me fix this, it's driving me crazy!
This is the problem part:
Code: Select all
$insert = "INSERT INTO buyer ( `id` , `surname` , `firstname` , `email` , `phone` , `position` , `companyname` , `company_type` , `addressline1` , `addressline2` , `city` , `postcode` , `country` , `username` , `password` , `approve` , `last_login` )
VALUES ('',
'".$_POST['surname_txt']."',
'".$_POST['firstname_txt']."',
'".$_POST['email_txt']."',
'".$_POST['phone_txt']."',
'".$_POST['position_txt']."',
'".$_POST['companyname_txt']."',
'".$_POST['companytype_txt']."',
'".$_POST['addressline1_txt']."',
'".$_POST['addressline2_txt']."',
'".$_POST['city_txt']."',
'".$_POST['postcode_txt']."',
'".$_POST['country_txt']."',
'".$_POST['username_txt']."',
'".$_POST['password_txt']."',
'',''
)";
echo $insert;
$insert_result = $connector->query($insert);
echo mysql_affected_rows();
if(mysql_affected_rows()) {
echo "An email has been sent to your email address. Your account is now
subject to approval. As soon as your account is approved you will receive
a confirmation email.";
}
else{
echo print_mysql_error();
}And when I fill in the form and hit submit button and echo $insert I get this:
Code: Select all
INSERT INTO buyer ( `id` , `surname` , `firstname` , `email` , `phone` , `position` , `companyname` , `company_type` , `addressline1` , `addressline2` , `city` , `postcode` , `country` , `username` , `password` , `approve` , `last_login` ) VALUES ('', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', '', 'a', 'a', '', 'as', 'f970e2767d0cfe75876ea857f92e319b', '','' )1An email has been sent to your email address. Your account is now subject to approval. As soon as your account is approved you will receive a confirmation email.and to make more sense, when the page is refreshed it says, the username exist please take a different name to show that this query worked just fine.
But when I go the database I see nothing there, and even from admin panel where the buyer details goes for approval it does not appear there either.
I thought something could be wrong with my insert statement (even though I was 100% sure there cant be as it returned 1) I copied the insert statement (I echoed it remember) and then open phpmyadmin, run that exact same query and only then it inserts a record and only then from admin panel you can see a new buyer joining is subject to approval.
Here is my database table :
Code: Select all
CREATE TABLE `buyer` (
`id` int(11) NOT NULL auto_increment,
`surname` varchar(50) NOT NULL default '',
`firstname` varchar(50) NOT NULL default '',
`email` varchar(50) NOT NULL default '',
`phone` int(20) NOT NULL default '0',
`position` varchar(50) NOT NULL default '',
`companyname` varchar(70) NOT NULL default '',
`company_type` varchar(40) NOT NULL default '',
`addressline1` varchar(70) NOT NULL default '',
`addressline2` varchar(70) default NULL,
`city` varchar(20) NOT NULL default '',
`postcode` varchar(10) NOT NULL default '',
`country` varchar(20) NOT NULL default '',
`username` varchar(20) NOT NULL default '',
`password` varchar(20) NOT NULL default '',
`approve` int(1) NOT NULL default '0',
`last_login` date NOT NULL default '0000-00-00',
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=5 ;If anybody is interested to run this code on their own server I can give you the full code.
Please help me fix this, it's driving me crazy!