logo-dw

Go Back   Dreamweaver Club Forums > Dreamweaver forums > Video Tutorials
Register FAQ Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
Old 12-12-2007, 10:53 PM   #1
irock
 
Join Date: Dec 2007
Posts: 6
Default Problem "One of your fields is empty" - PHP Video tuts Part9

I'm having a problem with part 9 of the PHP video tutorials.
I'm not sure exactly where I went wrong with it but I would guess its just the syntax - It can be hard to spot the difference between () and {} in the video, maybe thats what my mistake is.

Anyway, everytime I run the page at the end of the tutorial I get the echoed result "One of yout fields is empty !"

Heres what my dwc.php file looks like:

http://pastie.caboo.se/127816

I pasted it there rather than making the thread unreadable.
irock is offline   Reply With Quote
Old 12-13-2007, 06:42 AM   #2
davidj
davidj's Avatar
 
Join Date: Sep 2005
Location: The Toon (newcastle upon Tyne)
Posts: 8,256
Default

you have named your fields

textfield
textfield2
textfield3

they should reflect the $_POST references
__________________
Would you like to learn PHP from me? Check out -> www.codezenith.co.uk
davidj is offline   Reply With Quote
Old 12-13-2007, 12:11 PM   #3
lux
 
Join Date: Apr 2006
Posts: 313
Default

This is wrong:
PHP Code:
<td><?php echo $row{'field2'};?></td>
This is right:
PHP Code:
<td><?php echo $row['field2']; ?></td>
$row is an associate array that contains the values returned from the database query

to see all the ids and values in the array use the function var_dump() like this

PHP Code:
<?php var_dump($row?>
lux is offline   Reply With Quote
Old 12-13-2007, 01:42 PM   #4
davidj
davidj's Avatar
 
Join Date: Sep 2005
Location: The Toon (newcastle upon Tyne)
Posts: 8,256
Default

or

PHP Code:
echo "<pre>";
print_r($row);
echo 
"</pre>"
__________________
Would you like to learn PHP from me? Check out -> www.codezenith.co.uk
davidj is offline   Reply With Quote
Old 12-13-2007, 07:17 PM   #5
irock
 
Join Date: Dec 2007
Posts: 6
Default

I've changed the names of the fields to data2, data3, data2

Now I get "Column count doesn't match value count at row 1" on submitting.

I'm getting lost.
irock is offline   Reply With Quote
Old 12-13-2007, 07:20 PM   #6
irock
 
Join Date: Dec 2007
Posts: 6
Default

Quote:
Originally Posted by irock View Post
I've changed the names of the fields to data2, data3, data2

Now I get "Column count doesn't match value count at row 1" on submitting.

I'm getting lost.
Just realised its because I was trying to insert a value into field1 which autoincrements.


Wrong:
PHP Code:
$query sprintf("INSERT into table1 (field1, field2, field3, field4) values ('$data2', '$data3', '$data4')");
         
mysql_query($query)or die(mysql_error()); 

Right:

PHP Code:
$query sprintf("INSERT into table1 (field2, field3, field4) values ('$data2', '$data3', '$data4')");
         
mysql_query($query)or die(mysql_error()); 

I think I'm starting to grasp it. I suppose the key is to stick with it.
irock is offline   Reply With Quote
Old 12-14-2007, 07:30 AM   #7
davidj
davidj's Avatar
 
Join Date: Sep 2005
Location: The Toon (newcastle upon Tyne)
Posts: 8,256
Default

the reason you got the error is because in your SQL Insert statement you have 4 columns declared but only 3 variables with data

the error you get tells you this...

"Column count doesn't match value count at row 1".

PHP Code:
(field1field2field3field4values ('$data2''$data3''$data4')"); 
__________________
Would you like to learn PHP from me? Check out -> www.codezenith.co.uk
davidj is offline   Reply With Quote
Reply


Thread Tools
Display Modes

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

Forum Jump


All times are GMT. The time now is 02:17 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Copyright 2006 DreamweaverClub.com