Page 1 of 1

Adding to mysql

Posted: Sat Jun 28, 2003 2:48 pm
by Zeceer
What is actually wrong here? I've double checkes everything but it still doesn't add anything to the database.

Code: Select all

$link = mysql_connect( $hostname, $username, $password );

mysql_select_db( $db )
                 or die ( "Couldn't open $db: ".mysql_error() );

//The query adding the data to the database

$query = "INSERT INTO products ( prodnr, category, product, price, info, short_info, weight, image )
          VALUES( '".$_POSTї'prodnr']."', '".$_POSTї'category']."', '".$_POSTї'product'].$_POSTї'price'].$_POSTї'info']."', '".$_POSTї'short_info']."', '".$_POSTї'weight']."', '".$_POSTї'image']."' )";

mysql_query( $query, $link )
             or die (" Couldn't add data to "products" table: "
             .mysql_error() );

mysql_close( $link );
This is the error I get:

Code: Select all

Couldn't add data to "products" table: Column count doesn't match value count at row 1

Posted: Sat Jun 28, 2003 6:51 pm
by qartis

Code: Select all

$query = "INSERT INTO products ( `prodnr` , `category` , `product` , `price` , `info` , `short_info` , `weight` , `image` )
          VALUES( '".$_POST['prodnr']."' , '".$_POST['category']."' , '".$_POST['product']."' , '".$_POST['price']."' , '".$_POST['info']."' , '".$_POST['short_info']."' , '".$_POST['weight']."' , '".$_POST['image']."' )";
You had a few feilds concatenated into one, so mysql only received 6 values to fill 8 feilds.