我正在尝试从用户数据库中获取用户名 ID,我从会话中获得的数据是用户名,所以我有代码来选择用户名 ID 并将其存储到可验证中
我的代码是它存储上传的图像字符串,但只允许登录用户上传图像。加载图像时,我想将 userID 存储在带有字符串的照片表中,以了解哪个用户添加了照片
//setting veriables
$imagestring = $_FILES["file"]["name"];
$filetype = $_FILES["file"]["type"];
$sessionusername = $_SESSION['Username'];
$description = $_POST['desc'];
//getting user id
$myquery = mysql_query("select UserID from users where Username = '$sessionusername'");
$row = mysql_fetch_array($query);
// putting data into database
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$sql='INSERT INTO '.$tbl_name.' (photographerID, photoDesc, PhotoString) VALUES ('$row', '$description', "k00138899.atspace.eu/photoalbum/upload/'.$imagestring.'.'.$filetype.'")';
$result=mysql_query($sql);