彼のIDからデータベーステーブルからユーザー名を取得し、それを他のデータテーブルに入れたい
function upload_image($image_temp, $image_ext, $album_id, $image_n, $image_description) {
$album_id = (int)$album_id;
$image_n = mysql_real_escape_string(htmlentities($image_n));
$image_description = mysql_real_escape_string(htmlentities($image_description));
//$download_link = 'uploads/'. $album_id. '/'. $image['id']. '.'. $image_ext;
$mysql_date_now = date("Y-m-d (H:i:s)");
$user_name = mysql_query("SELECT `name` FROM `users` WHERE `user_id` = ".$_SESSION['user_id']);
mysql_query("INSERT INTO `images` VALUES ('', '".$_SESSION['user_id']."','$user_name', '$album_id', UNIX_TIMESTAMP(), '$image_ext', '$image_n', '$image_description', '','$mysql_date_now')");
$image_id = mysql_insert_id();
$download_link = 'uploads/'. $album_id. '/'. $image_id. '.'. $image_ext;
mysql_query("UPDATE `images` SET `download_link`='$download_link' WHERE `image_id`=$image_id ");
$selection = mysql_query("SELECT `user_two` FROM `follow` WHERE `user_one`='".$_SESSION['user_id']."'");
while ($row = mysql_fetch_array($selection)) {
mysql_query("INSERT INTO `notification` VALUES ('', '".$_SESSION['user_id']."', '".$row['user_two']."', '', UNIX_TIMESTAMP(), '$image_n', '$image_description', '$download_link')");
}
$image_file = $image_id.'.'.$image_ext;
move_uploaded_file($image_temp, 'uploads/'.$album_id.'/'.$image_file);
Thumbnail('uploads/'.$album_id.'/', $image_file, 'uploads/thumbs/'.$album_id.'/');
}
問題はここにあります
$user_name = mysql_query("SELECT `name` FROM `users` WHERE `user_id` = ".$_SESSION['user_id']);
mysql_query("INSERT INTO `images` VALUES ('', '".$_SESSION['user_id']."','$user_name', '$album_id', UNIX_TIMESTAMP(), '$image_ext', '$image_n', '$image_description', '','$mysql_date_now')");
これをデータベースで取得します (リソース ID #14)