Foros del Web » Programando para Internet » PHP »

insert me devuelve un 0

Estas en el tema de insert me devuelve un 0 en el foro de PHP en Foros del Web. hola amigos tiempo sin molestarlos e tengo un problemas con mi proyecto q e estado realizando y me di cuenta hasta hoy que ay un ...
  #1 (permalink)  
Antiguo 23/11/2011, 19:50
 
Fecha de Ingreso: abril-2010
Mensajes: 151
Antigüedad: 14 años
Puntos: 1
insert me devuelve un 0

hola amigos tiempo sin molestarlos e tengo un problemas con mi proyecto q e estado realizando y me di cuenta hasta hoy que ay un problema al hacer una insercion de datos en mi db cuando voy a insertar una url en un formulario esta la chequea a travez de curl o esta function
Código PHP:
public static function getUrlContent($Url){
       
// USAMOS CURL O FILE
       
if(function_exists('curl_int')){
            
// User agent
            
$useragent "Mozilla/5.0 (Windows; U; Windows NT 5.1; es-ES; rv:1.9) Gecko/2008052906 Firefox/3.0";
            
//Abrir conexion
            
$ch curl_init();
            
curl_setopt($chCURLOPT_USERAGENT$useragent);
            
curl_setopt($ch,CURLOPT_URL,$Url);
            
curl_setopt ($chCURLOPT_TIMEOUT60);
            
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
            
$result curl_exec($ch);
            
curl_close($ch);
        } else {
            
$result = @file_get_contents($Url);
        }
        return 
$result;
    } 
si esta exite o no y para hacer estos datos validos los hago asi

Código PHP:
public function Verific($return false$urlin null)
   {

 
$type Input::get('type');
        
$url = empty($urlin) ? Input::post('url') : $urlin;
        
// VALIDAR
        
if(empty($url)){
            return 
'0: El campo <b>url</b> es obligatorio.';
        }
        
//
        
switch($type){

case 
'enlace':
                
// VALIDAR
                
if(strlen($url) > 400){
                    return 
'0: La url es demasiado larga.';
                }
                
$data Url::getUrlContent($url);
                
// VALIDAR #1
                
if(!$data){
                    return 
'0: El enlace ingresado no es v&aacute;lido, no esta disponible o no existe.';
                }
                
// OBTENER META TITULO
                
$title explode('<title>',$data);
                
$title explode('</title>',$title[1]);
                
$title = empty($title[0]) ? $url $title[0];
                
// VALIDAR #2
                
if(!$title){
                    return 
'0: La url ingresada no es una p&aacute;gina web v&aacute;lida.';
                }
                
// RETORNAMOS HTML/VALOR
                
if($return == false){
                    return 
'1: <center><a href="'.$url.'" target="_blank" class="big a_blue">'.$title.'</a><br/><span class="desc">'.$url.'</span></center>';
                }else{
                    return array(
'title' => Security::antiSQL ($title), 'url' => Security::antiSQL($url));
                }
            break;

}

luego de verificar damos al boton publicar y alli donde inserta los datos aqui


Código PHP:
private function enlaceMuro($pid,$data,$adj,$type) {
         
$date time();
          
$enlace $this->ajaxCheck(true$adj);
          
$insermuroEnlace[] = array('p_user' => $pid,'p_user_pub' => $this->User->uid,'p_body' => $data,'p_date' => $date,'p_type'=> 3);
               
               foreach(
$insermuroEnlace as $insert) {
               
$this->db->insert_array('muro'$insert);
               
$pub_id $this->db->insert_id();
               
$insermuroAdjuntos[] = array('pub_id' => $pub_id,'a_title' => $enlace['title'],'a_url' => $enlace['url']);
               
               foreach(
$insermuroAdjuntos as $insertadj) {
                 
$this->db->insert_array('muro_adjuntos'$insertadj);
              
               
$type 'mlink';
                        
// RETORNAMOS DATOS PARA EL TEMPLATE
                        
$return = array('pub_id' => $pub_id'p_user' => $pid'p_user_pub' => $this->User->uid'p_body' => $this->Core->setMenciones($data), 'p_date' => $date'p_likes' => 0'p_type' => 3'likes' => array('link' => 'Me gusta'), 'a_title' => $enlace['title'], 'a_url' => $enlace['url']);   
                   } 
               }
               
               return 
$return;
    } 
pero cuando coloco una url como esta http://www.youtube.com/results?searc...s+mysql&page=3
me devuelve un valor de 0 en las filas de la db con son a_url y a_title pero cuando la url es asi
http://www.youtube.com/watch?v=5yZQ7hdySno tranquilamente no pasa eso todo lo inserta normalmente

Etiquetas: devuelve, insert-tabla, mysql, valor0
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 06:47.