By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,880 Members | 2,279 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,880 IT Pros & Developers. It's quick & easy.

Column count doesn't match value count at row 1

P: 4
i have this table in my database:
CREATE TABLE FILM(
F_ID INT(5) NOT NULL AUTO_INCREMENT,
F_TITLE VARCHAR(40) NOT NULL,
DIRECTOR_FNAME VARCHAR(20) NOT NULL,
DIRECTOR_LNAME VARCHAR(20) NOT NULL,
TYPE VARCHAR(30) NOT NULL,
DURATION TIME ,
YEAR_RELEASE YEAR NOT NULL,
DESCRIPTION TEXT,
RENT_TIME SMALLINT(2),
PRICE VARCHAR(4) NOT NULL ,
F_EMPLOYEE_ID INT(3),
PRIMARY KEY(F_ID),
UNIQUE(F_TITLE),
CONSTRAINT CRS
FOREIGN KEY (F_EMPLOYEE_ID) REFERENCES EMPLOYEE(E_ID)
ON DELETE CASCADE ON UPDATE CASCADE
);

i have 2 files:
//form_reg_film.htm
<html><center><head><title>ΕΓΓΡΑΦΗ ΤΑΙΝΙΑΣ</title></head>
<body bgcolor="#6699FF">
<h3> ΕΓΓΡΑΦΗ ΤΑΙΝΙΑΣ </h3>
<form name=reg_film action=reg_film.php method="POST"><table border=0>
<tr><td align = left>TΙΤΛΟΣ:</td><td align=left><input type=text size=40 name=F_TITLE MAXLENGTH=40 AUTOCOMPLETE=ON></td></tr>
<tr><td align = left>ΟΝΟΜΑ ΣΚΗΝΟΘΕΤΗ:</td>
<td align=left><input type=text size=20 name=DIRECTOR_FNAME MAXLENGTH=20 AUTOCOMPLETE=ON></td></tr>
<tr><td align = left>ΕΠΩΝΥΜΟ ΣΚΗΝΟΘΕΤΗ:</td>
<td align=left><input type=text size=20 name=DIRECTOR_LNAME MAXLENGTH=20 AUTOCOMPLETE=ON></td></tr>
<tr><td align = left>ΚΑΤΗΓΟΡΙΑ:</td>
<td lign=left><select name=TYPE size="1">
<option selected value="Category">All categories</option>
<option value="Action & Adventure" >Action & Adventure</option>
<option value="Comedy" >Comedy</option>
<option value="Cult" >Cult</option></select></td></tr>
<tr><td align = left>ΔΙΑΡΚΕΙΑ:</td><td align=left>
<select name=hour size="1" >
<option selected value="hour">hour</option><option value="00">00</option>
<option value="01">01</option></select>
: <select name=minute size="1">
<option selected value="minute">minute</option>
<option value="00">00</option><option value="01">01</option>
<option value="02">02</option><option value="03">03</option>
<option value="04">04</option><option value="05">05</option>
<option value="06">06</option><option value="07">07</option>
<option value="08">08</option><option value="09">09</option>
<option value="10">10</option><option value="11">11</option>
<option value="12">12</option><option value="13">13</option>
<option value="14">14</option><option value="15">15</option>
<option value="16">16</option><option value="17">17</option>
<option value="18">18</option><option value="19">19</option>
<option value="20">10</option><option value="21">21</option>
<option value="22">22</option><option value="23">23</option>
</select>
: <select name=second size="1">
<option selected value="second">second</option>
<option value="22">22</option><option value="23">23</option>
<option value="24">24</option><option value="25">25</option>
<option value="26">26</option><option value="27">27</option>
<option value="28">28</option><option value="29">29</option>
<option value="30">30</option><option value="31">31</option>
<option value="32">32</option><option value="33">33</option>
<option value="34">34</option><option value="35">35</option>
<option value="36">36</option><option value="37">37</option>
<option value="38">38</option><option value="39">39</option>
<option value="40">40</option><option value="41">41</option>
<option value="42">42</option><option value="43">43</option>
<option value="44">44</option><option value="45">45</option>
<option value="46">46</option><option value="47">47</option>
<option value="48">48</option><option value="49">49</option>
<option value="50">50</option><option value="51">51</option>
<option value="52">52</option><option value="53">53</option>
<option value="54">54</option><option value="55">55</option>
<option value="56">56</option><option value="57">57</option>
<option value="58">58</option><option value="59">59</option> </select></td></tr>
<tr><td align = left>ΈΤΟΣ ΠΑΡΑΓΩΓΗΣ:</td>
<td align=left><select name=rel_year size="1" >
<option selected value="year">year</option>
<option value="2000">2000</option><option value="2001">2001</option>
<option value="2002">2002</option><option value="2003">2003</option>
<option value="2004">2004</option><option value="2005">2005</option>
</select></td></tr>
<tr><td align = left>DVD COPIES:</td>
<td align=left><input type=text size=2 name=DVD_COPIES MAXLENGTH=2 AUTOCOMPLETE=ON></td></tr>

<tr><td align = left>VHS COPIES:</td><td align=left>
<input type=text size=2 name=VHS_COPIES MAXLENGTH=2></td>
</tr><tr><td align = left>XΡΟΝΟΣ <BR>ΕΝΟΙΚΙΑΣΗΣ:</td><td align=left>
<input type=text size=3 name=RENT_TIME MAXLENGTH=3>
</td></tr>
<tr><td align = left>ΤΙΜΗ:</td><td align=left><input type=text size=4 name=PRICE MAXLENGTH=4 AUTOCOMPLETE=ON></td></tr>
<tr><td align = left>ΑΡ.ΤΑΥΤΟΤΗΤΑΣ<BR>ΥΠΑΛΛΗΛΟΥ*:</td>
<td align=left><input type=text size=7 name=F_EMPLOYEE_ID MAXLENGTH=7 ></td></tr>

<tr><td align = left><BR>ΠΕΡΙΓΡΑΦΗ*:<p>
<textarea rows="5" cols=25 name=DESCRIPTION></textarea></td></p></tr>
<tr>
<td align=center colspan=2>
<br><input type=submit name=submit_bt value="ΚΑΤΑΧΩΡΗΣΗ">
<input type=reset name=reset_bt value="ΚΑΘΑΡΙΣΜΟΣ"></td></tr></table>
</form></font></center></body></html>

and reg_film.php

<html><body bgcolor="#6699FF"><center><font face=verdana>

<?php
$f_title=$_POST['F_TITLE'];
$dir_fname=$_POST['DIRECTOR_FNAME'];
$dir_lname=$_POST['DIRECTOR_LNAME'];
$type=$_POST['TYPE'];
$hour=$_POST['hour'];
$minute=$_POST['minute'];
$second=$_POST['second'];
$duration=$hour.':'.$minute.':'.$second;
$rel_year=$_POST['rel_year'];
$d = "year";
$h = "hour:minute:second";
$descr=$_POST['DESCRIPTION'];
$dvd_cop=$_POST['DVD_COPIES'];
$vhs_cop=$_POST['VHS_COPIES'];
$rent_time=$_POST['RENT_TIME'];
$price=$_POST['PRICE'];
$f_em_id=$_POST['F_EMPLOYEE_ID'];
$check1 = -1;
$check2 = -1;
$conn=mysql_connect("localhost","root","");
mysql_select_db("video_club");
if(!empty($dvd_cop)){
if( $dvd_cop > 0 )
$check1 = 2;
else
$check1 = 1;
}
else
$check1 = 0;

if(!empty($vhs_cop))
{
if( $vhs_cop > 0 )
$check2 = 2;
else
$check2 = 1;
}
else
{$check2 = 0;}

if (!empty($f_title) && !empty($dir_fname) && !empty($dir_lname) && !empty($type) && $rel_year != $d && !empty($price) && !empty($rent_time))
{

$query = "SELECT * FROM film WHERE F_TITLE = '$f_title'";
$rs = mysql_query($query,$conn);
$num_rows = mysql_num_rows($rs);

if ($num_rows > 0) {
ECHO "<BR><a href='form_reg_film.htm'> return</a>";
mysql_close($conn);exit();}

if($check1 > 0 )
;
else if($check2 > 0 )
;
else{
ECHO "<br><a href='form_reg_film.htm'>return</a>";
exit();}
// Eisagogi sti vasi
$qr = "INSERT INTO actor VALUES ('";
$qr .= NULL . "','";
$qr .= $f_title . "','";
$qr .= $dir_fname . "','";
$qr .= $dir_lname . "','";
$qr .= $type . "','";

if($duration == $h)
{$qr .= NULL. "','";}
else
{$qr .= $duration . "','";}

if($rel_year == $d)
{$qr .= NULL . "','";}
else
{$qr .= $rel_year . "','";}

if(empty($descr))
{$qr .= NULL . "','";}
else
{$qr .= $descr . "','"; }
$qr .= $rent_time . "','";
$qr .= $price . "','";
if(empty($f_em_id))
{$qr .= NULL. "')";}
else
{$query = "SELECT * FROM employee WHERE E_ID = 'f_em_id'";
$res = mysql_query($query,$conn);
$rows = mysql_num_rows($res);

if ($rows > 0)
{$qr .= $f_em_id . "')";}
else
{
ECHO "<br><a href='form_reg_film.htm'>ΕΠΙΣΤΡΟΦΗ</a>";

$r = mysql_query($qr) or die('ΛΑΝΘΑΣΜΑΝΟΣ ΚΩΔΙΚΟΣ ΕΡΓΑΖΟΜΕΝΟΥ ' . mysql_error());
exit();
}
}

$rs = mysql_query($qr) or die('ΑΔΥΝΑΤΗ Η ΕΓΓΡΑΦΗ ΤΗΣ ΝΕΑΣ ΤΑΙΝΙΑΣ: ' . mysql_error());
$insert_id = mysql_insert_id();

$qu = "INSERT INTO dvd_copies VALUES ('";
$qu .= $insert_id . "','";
$qu .= $check1 . "','";
$qu .= $dvd_cop . "')";
$rs = mysql_query($qu) or die('Query failed: ' . mysql_error());


$que = "INSERT INTO vhs_copies VALUES ('";
$que .= $insert_id . "','";
$que .= $check2 . "','";
$que .= $vhs_cop . "')";
$rs = mysql_query($que) or die('Query failed: ' . mysql_error());

mysql_close($conn);
ECHO "Η ΕΓΓΡΑΦΗ ΤΗΣ ΤΑΙΝΙΑΣ ΕΙΝΑΙ ΕΠΙΤΥΧΗΣ!";
}
else
{
ECHO "Η ΕΓΓΡΑΦΗ ΤΗΣ ΤΑΙΝΙΑΣ ΑΠΕΤΥΧΕ!";
ECHO "<BR>ΠΡΟΣΠΑΘΗΣΤΕ ΞΑΝΑ!";
mysql_close($conn);
}

?>
</body>
</html>

but when i try to insert i have this error:
Column count doesn't match value count at row 1

i saw for differrences in variables names , the number of columns but nothing...
anything to propose...????
thanks in advanced!!!!!
Jul 7 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.