Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Problem with mysql query
Old 12-12-2011, 04:11 AM Problem with mysql query
Novice Talker

Posts: 14
Trades: 0
Hello. I have one problem. This is the code:

PHP Code:
$category implode("', '",$_POST['category']);
$category1 "'".$category."'";
$group $_POST['group'];
$name $_POST['name'];
$product $_POST['product'];
$performance $_POST['performance'];
$service $_POST['service'];
$price $_POST['price'];

mysql_query("INSERT INTO system VALUES ('', '$group', $category1, '$product', '$performance', '$service', '$name', '$price')") or die(mysql_error());
        echo 
"Product posted successfuly"
I get this error: "Column count doesn't match value count at row 1".

I don't know what is the problem. When i delete $category1 in query, and post '', it works. But, i need that variable. Please, help me. Bye.
Ivan96 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 12-12-2011, 07:44 AM Re: Problem with mysql query
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,384
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
It's because there are more or less columns in the table than you have specified values for.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 12-12-2011, 12:47 PM Re: Problem with mysql query
orionoreo's Avatar
Ultra Talker

Posts: 335
Name: Jerry
Trades: 0
exactly as chris said i'm guessing you have some columns that you're not filling out maybe a created at or updated at so the easier way is to defined the columns to insert into:

Code:
mysql_query("INSERT INTO system(col_group, col_cat1, cold_product,...) VALUES ('$group', $category1, '$product', '$performance', '$service', '$name', '$price')"
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
orionoreo is offline
Reply With Quote
View Public Profile
 
Old 12-12-2011, 03:02 PM Re: Problem with mysql query
Novice Talker

Posts: 14
Trades: 0
I changed it, and now i get another error:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'group, categories, product, performance, service, name, price) ('', '1', 'panel'' at line 1

What can i do now?
Ivan96 is offline
Reply With Quote
View Public Profile
 
Old 12-12-2011, 03:06 PM Re: Problem with mysql query
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,384
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
print the query to the browser instead of sending it to the server so you can see what is wrong.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 12-12-2011, 05:55 PM Re: Problem with mysql query
orionoreo's Avatar
Ultra Talker

Posts: 335
Name: Jerry
Trades: 0
('', '1', 'panel''

if it's auto increment/id you don't need the '', at the beginning. Start with the group column
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
orionoreo is offline
Reply With Quote
View Public Profile
 
Old 12-13-2011, 04:09 AM Re: Problem with mysql query
Novice Talker

Posts: 14
Trades: 0
I fount what is the problem. It was in implode function. My function looks like this now:

$category = implode(", ",$_POST['category']);

Thanks for answers. Bye.
Ivan96 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Problem with mysql query
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.40176 seconds with 12 queries