Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/232.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何设置个人资料图片_Php_Html - Fatal编程技术网

Php 如何设置个人资料图片

Php 如何设置个人资料图片,php,html,Php,Html,如果我点击设置配置文件pic意味着,我想在配置文件pic上设置该图像,我已设置该图像值,我必须存储1剩余值,我必须存储0,在我的代码中,它将仅插入0 $sql=mysql_query("SELECT id FROM useralbum WHERE isprofilepic IN ('1') AND ssmid='$ssmid'"); $count = mysql_num_rows($sql); if($count == '1'){ while($row=mysql_fetch_assoc($s

如果我点击设置配置文件pic意味着,我想在配置文件pic上设置该图像,我已设置该图像值,我必须存储1剩余值,我必须存储0,在我的代码中,它将仅插入0

$sql=mysql_query("SELECT id FROM useralbum WHERE isprofilepic IN ('1') AND ssmid='$ssmid'");
$count = mysql_num_rows($sql);
if($count == '1'){
 while($row=mysql_fetch_assoc($sql)){
   $profileid = $row['id'];
 }
 $profile=mysql_query("UPDATE useralbum SET isprofilepic='0' WHERE id='$profileid'");
 if($profile){
     echo "SUCCESS";
 }
 else{
    echo "ERROR".mysql_error(); 
 } 
}  

else{    
 $newprofile=mysql_query("UPDATE useralbum SET isprofilepic='1' WHERE isprofilepic='".$_SESSION['profile']."'");
  if($newprofile){
     echo "SUCCESS";
 }
 else{
    echo "ERROR".mysql_error(); 
 } 
} 

在你的情况下有个问题。如果有以前的个人资料图片 . 然后它会进入这个街区。它永远不会进入其他部分,所以永远不要为新的配置文件pic设置1

if($count == '1'){
 while($row=mysql_fetch_assoc($sql)){
   $profileid = $row['id'];
 }
 $profile=mysql_query("UPDATE useralbum SET isprofilepic='0' WHERE id='$profileid'");
 if($profile){
     echo "SUCCESS";
 }
 else{
    echo "ERROR".mysql_error(); 
 } 
} 
在这种情况下,在更新以前的记录后,您不会更改新的配置文件pic记录。如果在此之前没有设置配置文件pic,则它可以工作。它将进入其他部分。但是,如果配置文件pic已经设置好了,而您更改了它,该怎么办呢。所以改变你的状况

$sql=mysql_query("SELECT id FROM useralbum WHERE isprofilepic="1" AND ssmid='$ssmid'");
$count = mysql_num_rows($sql);

//If there is already profile pic set then if block executes and set it to 0.
if($count == '1'){
 while($row=mysql_fetch_assoc($sql)){
   $profileid = $row['id'];
 }
 $profile=mysql_query("UPDATE useralbum SET isprofilepic='0' WHERE id='$profileid'");
 if($profile){
     echo "SUCCESS";
 }
 else{
    echo "ERROR".mysql_error(); 
 } 
}  

   //After setting previous pic 0, update new pic to 1. (This will works on both cases if already profile pic is set and there is first time setting profile pic )
 $newprofile=mysql_query("UPDATE useralbum SET isprofilepic='1' WHERE ssmid='$ssmid'");
  if($newprofile){
     echo "SUCCESS";
 }
 else{
    echo "ERROR".mysql_error(); 
 } 

威尔会给你准确的记录。试试这一个。

这是你的情况下的问题。如果有以前的个人资料图片 . 然后它会进入这个街区。它永远不会进入其他部分,所以永远不要为新的配置文件pic设置1

if($count == '1'){
 while($row=mysql_fetch_assoc($sql)){
   $profileid = $row['id'];
 }
 $profile=mysql_query("UPDATE useralbum SET isprofilepic='0' WHERE id='$profileid'");
 if($profile){
     echo "SUCCESS";
 }
 else{
    echo "ERROR".mysql_error(); 
 } 
} 
在这种情况下,在更新以前的记录后,您不会更改新的配置文件pic记录。如果在此之前没有设置配置文件pic,则它可以工作。它将进入其他部分。但是,如果配置文件pic已经设置好了,而您更改了它,该怎么办呢。所以改变你的状况

$sql=mysql_query("SELECT id FROM useralbum WHERE isprofilepic="1" AND ssmid='$ssmid'");
$count = mysql_num_rows($sql);

//If there is already profile pic set then if block executes and set it to 0.
if($count == '1'){
 while($row=mysql_fetch_assoc($sql)){
   $profileid = $row['id'];
 }
 $profile=mysql_query("UPDATE useralbum SET isprofilepic='0' WHERE id='$profileid'");
 if($profile){
     echo "SUCCESS";
 }
 else{
    echo "ERROR".mysql_error(); 
 } 
}  

   //After setting previous pic 0, update new pic to 1. (This will works on both cases if already profile pic is set and there is first time setting profile pic )
 $newprofile=mysql_query("UPDATE useralbum SET isprofilepic='1' WHERE ssmid='$ssmid'");
  if($newprofile){
     echo "SUCCESS";
 }
 else{
    echo "ERROR".mysql_error(); 
 } 

威尔会给你准确的记录。试试这个。

我不懂jazz,我必须在哪里更改,我犯了错误,你能更新你的查询吗?jazz 0只插入了什么,1没有插入什么值是
$\u会话['profile']
。有ssmid吗?如果是,则在设置
1
时您的查询是错误的$newprofile=mysql_查询(“更新用户相册集isprofilepic='1',其中ssmid='$ssmid'”;如果($newprofile){$_SESSION['profile']值是像5650111b7919a.pngok这样的photoname,那么您在isprofilepic?1/0或profile pic name中存储的值是什么?因为在
$newprofile=mysql_查询中(“更新用户相册集isprofilepic='1',其中isprofilepic='.$_SESSION['profile'.'”);
您正在与错误的字段进行比较。如果isprofilepic为0/1,则您的
isprofilepic='”$\u会话['profile']。“
将不会更新您的记录。正如您所说的
$\u会话['profile']
是photoname。我不理解jazz,我必须在哪里更改,我犯了错误,你能更新你的查询吗?jazz 0只插入了什么,1没有插入什么值是
$\u会话['profile']
。有ssmid吗?如果是,那么你的查询在set
1
$newprofile=mysql\u查询时是错误的(“更新用户相册集isprofilepic='1'其中ssmid='$ssmid'”;如果($newprofile){$\u SESSION['profile']值是像5650111b7919a.pngok这样的photoname,那么您在isprofilepic中存储的值是什么?1/0或profile pic name?因为在
$newprofile=mysql_查询中(“更新用户相册集isprofilepic='1'其中isprofilepic='”。$\u SESSION['profile']”)
您正在与错误的字段进行比较。如果isprofilepic为0/1,则您的
isprofilepic='”$\u会话['profile']。“
将不会更新您的记录。正如您所说,
$\u会话['profile']
是photoname。