B
blankito1998
Beta
Verificado por Whatsapp
¡Usuario con pocos negocios! ¡Utiliza siempre saldo de Forobeta!
Claro, aquí tienes la versión completa de tu código con las mejoras integradas y las verificaciones necesarias:
PHP:// Consulta de los posts vistos por el usuario $quimy = mysqli_query($conexion, "SELECT * FROM viewpost WHERE users LIKE '%," . $id2 . ",%' GROUP BY idpost ORDER BY id DESC"); if (!$quimy) { die('Error en consulta viewpost: ' . mysqli_error($conexion)); } $profitaer = []; while ($filo = mysqli_fetch_assoc($quimy)) { if (isset($filo['idpost'])) { $profitaer[] = $filo['idpost']; } } $profitaer = implode(',', $profitaer); // Consulta de los posters que contienen archivos .mp4 $quimids = mysqli_query($conexion, "SELECT * FROM posters WHERE (photo LIKE '%.mp4%' OR photo2 LIKE '%.mp4%' OR photo3 LIKE '%.mp4%' OR photo4 LIKE '%.mp4%' OR photo5 LIKE '%.mp4%' OR photo6 LIKE '%.mp4%' OR photo7 LIKE '%.mp4%' OR photo8 LIKE '%.mp4%' OR photo9 LIKE '%.mp4%' OR photo10 LIKE '%.mp4%' OR photo11 LIKE '%.mp4%' OR photo12 LIKE '%.mp4%' OR photo13 LIKE '%.mp4%' OR photo14 LIKE '%.mp4%' OR photo15 LIKE '%.mp4%' OR photo16 LIKE '%.mp4%' OR photo17 LIKE '%.mp4%' OR photo18 LIKE '%.mp4%' OR photo19 LIKE '%.mp4%' OR photo20 LIKE '%.mp4%') ORDER BY id DESC"); if (!$quimids) { die('Error en consulta posters: ' . mysqli_error($conexion)); } $profitaereds = []; while ($filods = mysqli_fetch_assoc($quimids)) { if (isset($filods['id'])) { $profitaereds[] = $filods['id']; } } // Usar array_filter para evitar elementos vacíos $profitaerArray = array_filter(explode(',', $profitaer)); $profitaeredsArray = array_filter(explode(',', implode(',', $profitaereds))); $missingItems = array_diff($profitaerArray, $profitaeredsArray); // Si no hay idpost que faltan, selecciona aleatoriamente de posters if (empty($missingItems)) { // Selecciona un poster aleatorio $surym = mysqli_query($conexion, "SELECT * FROM posters WHERE (photo LIKE '%.mp4%' OR photo2 LIKE '%.mp4%' OR photo3 LIKE '%.mp4%' OR photo4 LIKE '%.mp4%' OR photo5 LIKE '%.mp4%' OR photo6 LIKE '%.mp4%' OR photo7 LIKE '%.mp4%' OR photo8 LIKE '%.mp4%' OR photo9 LIKE '%.mp4%' OR photo10 LIKE '%.mp4%' OR photo11 LIKE '%.mp4%' OR photo12 LIKE '%.mp4%' OR photo13 LIKE '%.mp4%' OR photo14 LIKE '%.mp4%' OR photo15 LIKE '%.mp4%' OR photo16 LIKE '%.mp4%' OR photo17 LIKE '%.mp4%' OR photo18 LIKE '%.mp4%' OR photo19 LIKE '%.mp4%' OR photo20 LIKE '%.mp4%') ORDER BY RAND() DESC LIMIT 1"); } else { // Selecciona un poster que no está en viewpost $surym = mysqli_query($conexion, "SELECT * FROM posters WHERE id NOT IN (SELECT idpost FROM viewpost WHERE users LIKE '%," . $id2 . ",%') AND (photo LIKE '%.mp4%' OR photo2 LIKE '%.mp4%' OR photo3 LIKE '%.mp4%' OR photo4 LIKE '%.mp4%' OR photo5 LIKE '%.mp4%' OR photo6 LIKE '%.mp4%' OR photo7 LIKE '%.mp4%' OR photo8 LIKE '%.mp4%' OR photo9 LIKE '%.mp4%' OR photo10 LIKE '%.mp4%' OR photo11 LIKE '%.mp4%' OR photo12 LIKE '%.mp4%' OR photo13 LIKE '%.mp4%' OR photo14 LIKE '%.mp4%' OR photo15 LIKE '%.mp4%' OR photo16 LIKE '%.mp4%' OR photo17 LIKE '%.mp4%' OR photo18 LIKE '%.mp4%' OR photo19 LIKE '%.mp4%' OR photo20 LIKE '%.mp4%') ORDER BY RAND() DESC LIMIT 1"); } // Verifica si la consulta final devuelve resultados if (!$surym) { die('Error en consulta final: ' . mysqli_error($conexion)); } // Obtener el resultado final if ($row = mysqli_fetch_assoc($surym)) { // Procesa el resultado aquí // Por ejemplo, puedes acceder a los datos de la fila: // $row['column_name']; } else { echo "No se encontraron resultados."; }
### Principales Aspectos Incluidos:
1. Verificaciones de Errores: Se agrega el manejo de errores para cada consulta SQL.
2. Validación de Resultados: Se asegura que los arrays no contengan elementos vacíos.
3. Lógica Condicional: Se mantiene la lógica para comprobar si hay elementos faltantes y se ajustan las consultas en consecuencia.
4. Consulta Final: Se asegura que se manejen los resultados de la consulta final de forma adecuada.
Este código debería ayudarte a evitar problemas y hacer un manejo más eficiente de las consultas SQL. Si aún tienes dudas o necesitas más ajustes, ¡háznoslo saber!
$quimy = mysqli_query($conexion, "SELECT * FROM viewpost WHERE users LIKE '%," . $id2 . ",%' GROUP BY idpost ORDER BY id DESC");
if (!$quimy) {
die('Error en consulta viewpost: ' . mysqli_error($conexion));
}
$profitaer = [];
while ($filo = mysqli_fetch_assoc($quimy)) {
if (isset($filo['idpost'])) {
$profitaer[] = $filo['idpost'];
}
}
$profitaer = implode(',', $profitaer);
// Consulta de los posters que contienen archivos .mp4
$quimids = mysqli_query($conexion, "SELECT * FROM posters WHERE (photo LIKE '%.mp4%' OR photo2 LIKE '%.mp4%' OR photo3 LIKE '%.mp4%' OR photo4 LIKE '%.mp4%' OR photo5 LIKE '%.mp4%' OR photo6 LIKE '%.mp4%' OR photo7 LIKE '%.mp4%' OR photo8 LIKE '%.mp4%' OR photo9 LIKE '%.mp4%' OR photo10 LIKE '%.mp4%' OR photo11 LIKE '%.mp4%' OR photo12 LIKE '%.mp4%' OR photo13 LIKE '%.mp4%' OR photo14 LIKE '%.mp4%' OR photo15 LIKE '%.mp4%' OR photo16 LIKE '%.mp4%' OR photo17 LIKE '%.mp4%' OR photo18 LIKE '%.mp4%' OR photo19 LIKE '%.mp4%' OR photo20 LIKE '%.mp4%') ORDER BY id DESC");
if (!$quimids) {
die('Error en consulta posters: ' . mysqli_error($conexion));
}
$profitaereds = [];
while ($filods = mysqli_fetch_assoc($quimids)) {
if (isset($filods['id'])) {
$profitaereds[] = $filods['id'];
}
}
// Usar array_filter para evitar elementos vacíos
$profitaerArray = array_filter(explode(',', $profitaer));
$profitaeredsArray = array_filter(explode(',', implode(',', $profitaereds)));
$missingItems = array_diff($profitaerArray, $profitaeredsArray);
// Si no hay idpost que faltan, selecciona aleatoriamente de posters
if (empty($missingItems)) {
// Selecciona un poster aleatorio
$surym = mysqli_query($conexion, "SELECT * FROM posters WHERE (photo LIKE '%.mp4%' OR photo2 LIKE '%.mp4%' OR photo3 LIKE '%.mp4%' OR photo4 LIKE '%.mp4%' OR photo5 LIKE '%.mp4%' OR photo6 LIKE '%.mp4%' OR photo7 LIKE '%.mp4%' OR photo8 LIKE '%.mp4%' OR photo9 LIKE '%.mp4%' OR photo10 LIKE '%.mp4%' OR photo11 LIKE '%.mp4%' OR photo12 LIKE '%.mp4%' OR photo13 LIKE '%.mp4%' OR photo14 LIKE '%.mp4%' OR photo15 LIKE '%.mp4%' OR photo16 LIKE '%.mp4%' OR photo17 LIKE '%.mp4%' OR photo18 LIKE '%.mp4%' OR photo19 LIKE '%.mp4%' OR photo20 LIKE '%.mp4%') ORDER BY RAND() DESC LIMIT 1");
} else {
// Selecciona un poster que no está en viewpost
$surym = mysqli_query($conexion, "SELECT * FROM posters WHERE id NOT IN (SELECT idpost FROM viewpost WHERE users LIKE '%," . $id2 . ",%') AND (photo LIKE '%.mp4%' OR photo2 LIKE '%.mp4%' OR photo3 LIKE '%.mp4%' OR photo4 LIKE '%.mp4%' OR photo5 LIKE '%.mp4%' OR photo6 LIKE '%.mp4%' OR photo7 LIKE '%.mp4%' OR photo8 LIKE '%.mp4%' OR photo9 LIKE '%.mp4%' OR photo10 LIKE '%.mp4%' OR photo11 LIKE '%.mp4%' OR photo12 LIKE '%.mp4%' OR photo13 LIKE '%.mp4%' OR photo14 LIKE '%.mp4%' OR photo15 LIKE '%.mp4%' OR photo16 LIKE '%.mp4%' OR photo17 LIKE '%.mp4%' OR photo18 LIKE '%.mp4%' OR photo19 LIKE '%.mp4%' OR photo20 LIKE '%.mp4%') ORDER BY RAND() DESC LIMIT 1");
}
for(var i = 1; i <= 10; i++){
(function(index){
$.get("hola.php?qaly", function(molest){
var elementospro = document.querySelectorAll(".submeho");
if(elementospro.length > 0){
var elementoHTML = document.createElement("html");
elementoHTML.innerHTML = molest;
var texto = elementoHTML.getElementsByClassName("qaly")[0];
var tromes = '';
if(texto){
var wam = texto.getAttribute("dataid"); // Captura el valor de dataid aquí
// Asegúrate de que no se haya utilizado este dataid antes
if (!usedDataIds.has(wam)) {
usedDataIds.add(wam); // Añadir el dataid al conjunto
$.get("hola.php?newbird=" + wam + serd + remp + prush + climt + "&sutels", function(sumomni) {
tromes = '<div style="z-index:0;float:left;position:absolute;justify-content:center;justify-items:center;bottom:0px;height:100%;width:100%;display:flex;" subid="'+wam+'" class="drag-handle"></div><div class="acult1" subid="'+wam+'" style="background-image:url(./wpp/img/bt1092.png);top:55px;position:absolute;background-position:center center;background-color:rgba(0,0,0,0.5);background-repeat:no-repeat;background-size:20px 20px;border-radius:8px;height:40px;color:red;width:40px;float:left;right:10px;z-index:2;"></div>';
$("body").prepend('<article idcorm="'+wam+'" style="display:none;" result="' + index + '" class="meho dows'+wam+'"><div onclick="cleanhodter();" class="tempo">@</div><section class="hodter'+$valy+'">'+sumomni+tromes+'</section></article>');
if(document.querySelector('.dows'+wam)){
var intervala = setInterval(function() {
var div = document.getElementsByClassName('dows'+wam)[0];
if(!div){
clearInterval(intervala);
} else {
var dataId = wam;
$.get("hola.php?getlikes="+dataId, function(omspre) {
if(document.querySelector(".ok"+dataId)){
var prolike = document.getElementsByClassName("ok"+dataId)[0].getAttribute("data-like");
var laike = document.getElementsByClassName("ok"+dataId)[0].getAttribute("data");
var elementoHTML = document.createElement("html");
elementoHTML.innerHTML = omspre;
var texto = elementoHTML.getElementsByClassName("grand"+dataId)[0];
var wam = texto.getAttribute("data");
var wame = texto.getAttribute("datalikes");
if(texto.innerHTML !== prolike || wam !== laike){
document.getElementsByClassName("ok"+dataId)[0].setAttribute("data-like", texto.innerHTML);
if($(".inden"+dataId).text() !== wame){
$(".inden"+dataId).html(wame);
}
}
}
});
var datapost = wam;
$.get("hola.php?getposterall="+datapost, function(omsprod) {
if(document.querySelector(".eit"+datapost)){
var prolike = document.getElementsByClassName("eit"+datapost)[0].getAttribute("data-poster");
var elementoHTML = document.createElement("html");
elementoHTML.innerHTML = omsprod;
var texto2 = elementoHTML.getElementsByClassName("grands"+datapost)[0];
var wamer = texto2.getAttribute("data");
if(wamer !== prolike){
document.getElementsByClassName("eit"+datapost)[0].setAttribute("data-poster", wamer);
$(".eit"+datapost).html(wamer);
if(document.querySelector('.sofs')){
$(".sofs").html(omsprod);
}
}
}
});
}
}, 1000);
}
});
}
}
}
});
})(i); // Ejecutar la función con el valor actual de 'i'
}
porque hay idpost que no estan en viewpost y me da los resultados aleatorios?


