stonner
09-23-2007, 04:24 PM
I have a function to comment and rate photos.
It should insert the comment into the comment table in the DB. when i check it in the table, the comment-text and user_id are correctly inserted, but the photo_id is 0. (see screenshot)
Can someone help me with this?
Thank you very much
The function is the following:
function hon_save_vote(){
$info = auth_member();
$sql_query = "SELECT photos FROM photo_votes WHERE mem_id=".$info["mem_id"];
$exclude = $GLOBALS["DB"]->single($sql_query);
$exclude_photos = handle_empties(explode(",",$exclude));
$rating = $GLOBALS["Get"]->type_val("rating","integer");
$pho_id = $GLOBALS["Get"]->type_val("rate_pho_id","integer");
$comment = $GLOBALS["Get"]->val("comment");
if(!in_array($pho_id,$exclude_photos)){
$sql_query = "UPDATE photos SET rating=rating+".$rating.",votes=votes+1 WHERE pho_id=".$pho_id;
$GLOBALS["DB"]->execute($sql_query);
$sql_query = "UPDATE photo_votes SET photos=CONCAT(photos,'".$pho_id.",') WHERE mem_id=".$info["mem_id"];
$updated = $GLOBALS["DB"]->update($sql_query);
if(!$updated){
$sql_query = "INSERT INTO photo_votes (mem_id,photos) VALUES (".$info["mem_id"].",'".$pho_id.",')";
$GLOBALS["DB"]->execute($sql_query);
}//if
}//if
if($comment){
$sql_query = "INSERT INTO photo_comments (pho_id,mem_id,comment)
VALUES (:pho_id:,:mem_id:,':comment:')";
$vals["pho_id"] = $pho_id;
$vals["mem_id"] = $info["mem_id"];
$vals["comment"] = $comment;
$GLOBALS["DB"]->values = $vals;
$GLOBALS["DB"]->execute($sql_query);
}//if
$p_details["page"] = "";
$p_details["section"] = "";
$p_details["items_file"] = "";
build_page($p_details);
}//hon_save_vote
It should insert the comment into the comment table in the DB. when i check it in the table, the comment-text and user_id are correctly inserted, but the photo_id is 0. (see screenshot)
Can someone help me with this?
Thank you very much
The function is the following:
function hon_save_vote(){
$info = auth_member();
$sql_query = "SELECT photos FROM photo_votes WHERE mem_id=".$info["mem_id"];
$exclude = $GLOBALS["DB"]->single($sql_query);
$exclude_photos = handle_empties(explode(",",$exclude));
$rating = $GLOBALS["Get"]->type_val("rating","integer");
$pho_id = $GLOBALS["Get"]->type_val("rate_pho_id","integer");
$comment = $GLOBALS["Get"]->val("comment");
if(!in_array($pho_id,$exclude_photos)){
$sql_query = "UPDATE photos SET rating=rating+".$rating.",votes=votes+1 WHERE pho_id=".$pho_id;
$GLOBALS["DB"]->execute($sql_query);
$sql_query = "UPDATE photo_votes SET photos=CONCAT(photos,'".$pho_id.",') WHERE mem_id=".$info["mem_id"];
$updated = $GLOBALS["DB"]->update($sql_query);
if(!$updated){
$sql_query = "INSERT INTO photo_votes (mem_id,photos) VALUES (".$info["mem_id"].",'".$pho_id.",')";
$GLOBALS["DB"]->execute($sql_query);
}//if
}//if
if($comment){
$sql_query = "INSERT INTO photo_comments (pho_id,mem_id,comment)
VALUES (:pho_id:,:mem_id:,':comment:')";
$vals["pho_id"] = $pho_id;
$vals["mem_id"] = $info["mem_id"];
$vals["comment"] = $comment;
$GLOBALS["DB"]->values = $vals;
$GLOBALS["DB"]->execute($sql_query);
}//if
$p_details["page"] = "";
$p_details["section"] = "";
$p_details["items_file"] = "";
build_page($p_details);
}//hon_save_vote