Image Upload Question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
tsm4781
Forum Commoner
Posts: 38
Joined: Wed Jul 09, 2003 7:17 pm

Image Upload Question

Post by tsm4781 »

What in this code doesn't make sence??

I am getting the following error: Column count doesn't match value count at row 1

Code: Select all

<?php

	if ($_POST['action'] == 'uploadbandimage')
	{
		$name = $_POST['name'];
		$namearr = explode(".",$_FILES['file']['name']);
		$path = $_SERVER['DOCUMENT_ROOT']."/bands/";
		$filename = $namearr[0];
		$ext = $namearr[1];
		$query = "INSERT INTO bandimage(userid, name, filename) VALUES ($IYOY_UID, '$name', '$filename', NOW())";

		if (!empty($_FILES['file']) && !empty($name) && ($ext == "jpg" || $ext == "JPG" || $ext == "gif" || $ext == "jpeg" || $ext == "png"))
		{			
		if (is_uploaded_file($_FILES['file']['tmp_name']))
			{
				$filename = $IYOY_USER;
					move_uploaded_file($_FILES['file']['tmp_name'], $path.$filename.".".$ext);
				$filename = $filename.$ext;
			    $query = "INSERT INTO bandimage(userid, name, filename) VALUES ($IYOY_UID, '$name', '$filename', NOW())";
			    $result = mysql_query($query) OR DIE(mysql_error());
			}
				else {
					switch ($_FILES['file']['error'])
					{
						case 0:
							$errormsg = "<font color ='#FF0000'>File Uploaded</font>";
							break;
						case 1:
							$errormsg = "<font color ='#FF0000'>File Size Exceeded</font>";
							break;
						case 2:
							$errormsg = "<font color ='#FF0000'>File Size Exceeded</font>";
							break;
						case 3:
							$errormsg = "<font color ='#FF0000'>File Only Partially Uploaded</font>";
							break;
						case 4:
							$errormsg = "<font color ='#FF0000'>File Not Uploaded</font>";
							break;
					}
					$p = 3;		
			}		
		}
		else
		{
				$errormsg = "<font color ='#FF0000'>Not Complete or Wrong Type</font>";
				$p = 3;		
		}	
	}

?>
microthick
Forum Regular
Posts: 543
Joined: Wed Sep 24, 2003 2:15 pm
Location: Vancouver, BC

Post by microthick »

$query = "INSERT INTO bandimage(userid, name, filename) VALUES ($IYOY_UID, '$name', '$filename', NOW())";

Three fields, four values.
tsm4781
Forum Commoner
Posts: 38
Joined: Wed Jul 09, 2003 7:17 pm

Post by tsm4781 »

that did it, thanks!
Post Reply