PHP MySQL i'm sure it's just something stupid but it's ANNOYING THE CRAP OUT OF...

Mitch

New member
...ME.. HELP? i have a mysql database, and i'm trying to use an INSERT command from php, and for some reason if i enter text into the form it will error out, but if i put in numbers it will take them...

why???

$registerquery = mysql_query("
INSERT INTO users
(affiliate_username, affiliate_password, affiliate_first_name, affiliate_last_name, affiliate_office_phone, affiliate_cell_phone, affiliate_email_address, affiliate_address, affiliate_city, affiliate_state, affiliate_zip, affiliate_company_name, affiliate_threshold)
VALUES
('$affiliate_username', $affiliate_password, $affiliate_first_name, $affiliate_last_name, $affiliate_office_phone, $affiliate_cell_phone, $affiliate_email_address, $affiliate_address, $affiliate_city, $affiliate_state, $affiliate_zip, $affiliate_company_name, $affiliate_threshold)");

---------------------
(user id is set as primary key)

user_id int(11) No auto_increment

affiliate_username varchar(50) latin1_swedish_ci Yes NULL

affiliate_password varchar(50) latin1_swedish_ci Yes NULL

affiliate_first_name varchar(50) latin1_swedish_ci Yes NULL

affiliate_last_name varchar(50) latin1_swedish_ci Yes NULL

affiliate_office_phone varchar(50) latin1_swedish_ci Yes NULL

affiliate_cell_phone varchar(50) latin1_swedish_ci Yes NULL

affiliate_email_address varchar(50) latin1_swedish_ci Yes NULL

affiliate_address varchar(50) latin1_swedish_ci Yes NULL

affiliate_city varchar(50) latin1_swedish_ci Yes NULL

affiliate_state varchar(50) latin1_swedish_ci Yes NULL

affiliate_zip varchar(50) latin1_swedish_ci Yes NULL

affiliate_company_name varchar(50) latin1_swedish_ci Yes NULL

affiliate_threshold varchar(50) latin1_swedish_ci Yes NULL
ps when it says no auto incriment, the NO is actually for IS NULL.. so it means ... not null...
to the person who just sent me that link..... thanks for the spam. not what i was looking for.. please send specifics...
hey "what?"

that was the clue i needed... turns out, i forgot to 'put' , 'the' , 'rest' , of the stuff in quotes...

apparently if you don't do that, it only lets you insert numbers, and not text. i've never come across that.

Thanks for the tip...
 
To be more specific, your first column variable ($affiliate_username) in the values list has single quotes around it, making the variable name the value that will be inserted instead of the variable's value.

It should be:
VALUES
($affiliate_username, ...

NOT
VALUES
('$affiliate_username', ...

So, if you put in numbers for what values does it work? All of them?

If user_id is the primary key, why isn't it part of the insert statement? Seems to me like you need to include that or it won't work.
 
After VALUES you have an extra single quote in the username variable

VALUES
('$affiliate_username' <--

Other than that I'm not sure if your problem can be solved without more of your source.
 
Back
Top