Click to See Complete Forum and Search --> : Column count doesn't match value count at row 1 in MYSQL


pratik_learner
12-30-2005, 11:11 AM
$mysql_srv='127.0.0.1';
$user='root';
$pwd='secretword';

$link=mysql_connect($mysql_srv,$user,$pwd);

header('Content-type:text/plain');
$link?print_r("Connection compeleted\n"):die(mysql_error()."\nCan't Connect\n");

mysql_query("CREATE DATABASE IF NOT EXISTS ssqu")?print"DB ssqu created\n"
:die(mysql_error()."\nDB not created\n");

mysql_select_db('ssqu')?print"DB ssqu selected\n"
:die(mysql_error()."\nDB ssqu not selected\n");

$query="
CREATE TABLE IF NOT EXISTS table1 (
Path VARCHAR(250) NULL ,
Body VARCHAR(5000) NULL ,
Title VARCHAR( 100 ) NULL ,
Descr VARCHAR(600) NULL ,
Keywords VARCHAR(600) NULL ,
Author VARCHAR( 50 ) NULL ,
Title2 VARCHAR( 100 ) NULL
)";

mysql_query($query)
?print"Table1 on ssqu created\n"
:die(mysql_error()."\nTable1 not created\n");

$query="INSERT INTO table1 (Path, Body, Title, Descr, Keywords, Author, Title2) VALUES('path to heaven','Blah man blah dont you know it');";
mysql_query($query)?print"Inserted data\n":print"not goin the data\n\n".mysql_error();;

What's happening can anybody tell me using MySQL for 1st time

LazyJones
12-30-2005, 01:04 PM
I think you are using also SQL for the first time...

INSERT INTO table1 (Path, Body, Title, Descr, Keywords, Author, Title2) VALUES('path to heaven','Blah man blah dont you know it')

Here you are telling that you are inserting values to all the columns in the table, but you are giving only two values.

acorbelli
12-30-2005, 01:13 PM
What he means is, you're telling it that you're inserting "PAth, Body, Title, Descr, Keywords, Author, Title2" but you're only giving it two values (it looks like Path and Body).

Either give it more values, or remove some of the things you're telling it it has.

INSERT INTO table1 (Path, Body) VALUES('path to heaven','Blah man blah dont you know it')

Or...

INSERT INTO table1 (Path, Body, Title, Descr, Keywords, Author, Title2) VALUES('path to heaven','Blah man blah dont you know it', 'Pathway', 'Description of Pathway', 'pth', 'Author', 'Title2')


But changing those (latter) values to something you actually want, since I just made those up.