私が取り組んでいる大学のプロジェクトでこのエラーが発生します。各ユーザーには、「プロフィール画像」をアップロードして「自己紹介」を作成できるプロフィールがあります。ただし、プロファイル情報を送信しようとすると、エラーが発生します... 何かアイデアはありますか?
Column count doesn't match value count at row 1
これらは、エラーに関連する 2 つの PHP ファイルです...
rnprofile.php...
<?php // rnprofile.php
include_once 'rnheader.php';
if (!isset($_SESSION['user']))
die("<br /><br />You need to login to view this page");
$user = $_SESSION['user'];
echo "<h3>Edit your Profile</h3>";
$UserData = mysql_fetch_assoc(mysql_query("SELECT * FROM `rnprofiles` WHERE `user` = '$user'"));//Grabbing all info on the user
//print_r($UserData);
$UserExists = ($UserData!=null) ? true : false; // Seeing if the user exists (returns true if so, false if not
/*if ($UserExists==false) {
echo "we don't exist";
exit();
}*/
?>
</br>
<div id="container_profile">
<?php
if (isset($_POST['about']))
{
$about = sanitizeString($_POST['about']);
$about = preg_replace('/\s\s+/', ' ', $about);
$query = "SELECT * FROM rnprofiles WHERE user='$user'";
if (mysql_num_rows(queryMysql($query)))
{
queryMysql("UPDATE rnprofiles SET text='$about' where user='$user'");
}
else
{
$query = "INSERT INTO rnprofiles VALUES('$user', '$about')";
queryMysql($query);
}
}
else
{
$query = "SELECT * FROM rnprofiles WHERE user='$user'";
$result = queryMysql($query);
if (mysql_num_rows($result))
{
$row = mysql_fetch_row($result);
$about = stripslashes($row[4]);
}
else $about = "";
}
$about = stripslashes(preg_replace('/\s\s+/', ' ', $about));
if (isset($_FILES['profile']['name']))
{
$saveto = "$user.jpg";
move_uploaded_file($_FILES['profile']['tmp_name'], $saveto);
$typeok = TRUE;
switch($_FILES['profile']['type'])
{
case "profile/gif": $src = imagecreatefromgif($saveto); break;
case "profile/jpeg": // Both regular and progressive jpegs
case "profile/pjpeg": $src = imagecreatefromjpeg($saveto); break;
case "profile/png": $src = imagecreatefrompng($saveto); break;
default: $typeok = FALSE; break;
}
if ($typeok)
{
list($w, $h) = getimagesize($saveto);
$max = 600;
$tw = $w;
$th = $h;
if ($w > $h && $max < $w)
{
$th = $max / $w * $h;
$tw = $max;
}
elseif ($h > $w && $max < $h)
{
$tw = $max / $h * $w;
$th = $max;
}
elseif ($max < $w)
{
$tw = $th = $max;
}
$tmp = imagecreatetruecolor($tw, $th);
imagecopyresampled($tmp, $src, 0, 0, 0, 0, $tw, $th, $w, $h);
imageconvolution($tmp, array( // Sharpen image
array(-1, -1, -1),
array(-1, 16, -1),
array(-1, -1, -1)
), 8, 0);
imagejpeg($tmp, $saveto);
imagedestroy($tmp);
imagedestroy($src);
}
}
Profile($user);
echo <<<_END
<form method='post' action='rnprofile.php'
enctype='multipart/form-data'>
Enter or edit your details and/or upload an image:<br />
<textarea name='about' cols='40' rows='3'>$about</textarea>
Image: <input type='file' name='profile' size='1' maxlength='32' />
<input type='submit' value='Save Profile' />
</pre></form>
_END;
rnfunctions.php...
function Profile($user)
{
if (file_exists("$user.jpg"))
echo "<p><a title='' class='fancybox' href='$user.jpg'><img src='$user.jpg' border='1' align='left' height='200' width='200' alt=''/></a></p>";
echo "</br>";
$result = queryMysql("SELECT * FROM rnprofiles WHERE user='$user'");
if (mysql_num_rows($result))
{
$row = mysql_fetch_row($result);
echo stripslashes($row[2]) . "<br clear=left /><br />";
}
}