begin process at 2012 02 14 08:17:25
  Trouver un code source :
 
dans
 
Accueil > Forum > 

PHP

 > 

Base de données

 > 

MySQL

 > 

Error : MySQL server has gone away


Derniers messages déposésPoser une question dans le forum ou lancer une discussion

Error : MySQL server has gone away

samedi 9 mai 2009 à 18:47:32 | Error : MySQL server has gone away

soldier8514

Bonjour à tous !

j'ai un probleme de base de données avec ce script
MySql me retourne presque à chaque fois " Error : MySQL server has gone away "

pour résumer le script :

il charge une page web du site p0rnhub
puis il cherche les identifiants des vidéos qui sont sur la page
il cherche ensuite les images associées aux vidéos

( jusque là tout fonctionne très bien )

puis pour l'enregisrement dans la bdd il m'affiche "server has gone away "

quelqu'un à une idée ??







<?php

//session_start( );
include( "include/config.php" );
include( "include/functions/import.php" );
$thebaseurl = $config['baseurl'];


if ($_SESSION[USERID] != "" && $_SESSION[USERID] >= 0 && is_numeric($_SESSION[USERID]))
{
    function download_file( $file_source, $file_target )
    {
        //if ( file_exists( $file_target ) )
        //{
        //    echo "<br>file exist";
        //    return false;
        //}
        $rh = fopen( $file_source, "rb" );
        $wh = fopen( $file_target, "wb" );
        if ( $rh === false || $wh === false )
        {
           
            return false;
        }
        while ( !feof( $rh ) )
        {
            if ( fwrite( $wh, fread( $rh, 1024 ) ) === FALSE )
            {
               
                return false;
            }
        }
        fclose( $rh );
        fclose( $wh );
        //echo "<br>everything went ok ";
        return true;
    }
    function download_my_remote_thumbs( $thumb_url, $video_id )
    {
        global $config;

        //download the first thumbnail image
        download_file( $thumb_url.".jpg", $config['thumbdir']."/".$video_id."-1.jpg" );

        //make also a copy
        download_file( $config['thumbdir']."/".$video_id."-1.jpg", $config['thumbdir']."/".$video_id."-2.jpg" );
        download_file( $config['thumbdir']."/".$video_id."-1.jpg", $config['thumbdir']."/".$video_id."-3.jpg" );
        download_file( $config['thumbdir']."/".$video_id."-1.jpg", $config['thumbdir']."/".$video_id."-4.jpg" );
        download_file( $config['thumbdir']."/".$video_id."-1.jpg", $config['thumbdir']."/".$video_id."-5.jpg" );
        download_file( $config['thumbdir']."/".$video_id."-1.jpg", $config['thumbdir']."/".$video_id."-6.jpg" );
        download_file( $config['thumbdir']."/".$video_id."-1.jpg", $config['thumbdir']."/".$video_id."-7.jpg" );
        download_file( $config['thumbdir']."/".$video_id."-1.jpg", $config['thumbdir']."/".$video_id."-8.jpg" );
        download_file( $config['thumbdir']."/".$video_id."-1.jpg", $config['thumbdir']."/".$video_id."-9.jpg" );
        download_file( $config['thumbdir']."/".$video_id."-1.jpg", $config['thumbdir']."/".$video_id."-10.jpg" );


return true;
    }
    if ( isset( $_REQUEST['submit'] ) )
    {
        $keyword = $_REQUEST['keyword'];
        $amount = intval( $_REQUEST['amount'] );
        $category = intval( $_POST['category'] );
        if ( $keyword == "" )
        {
            $error = $langph['6'];  // msg : " Please enter a keyword to search for.";
        }
        else if ( $category <= "0" )
        {
            $error = $lang['462'];  //msg : " Please select a category.";
        }
        $videosperpage = "24";
        if ( !$error )
        {

            if ( $amount == "0" )
            {
                $amount = 1;
            }
            $page = 1;
            $validcount = 0;
            $addedvids = 0;
            while ( $validcount < $amount )
            {
                $html = file_get_contents( "http://www.pornhub.com/video/search?search=".$keyword."&page=".$page );
                preg_match_all( "/Broaden your(.+?)search/", $html, $nomatch );
                $noresult = array_unique( $nomatch );
               
                $rcount = count( $noresult[0] );
                $rmsg = $noresult[0][0];

                if ( 0 < $rcount )
                {
                    $validcount = $amount;
                    $rskip = "1";
                }
                if ( $rskip != "1" )
                {
                    preg_match_all( "/<a href = \"http:\\/\\/www.pornhub.com\\/view_video.php\\?viewkey=(.+?)\"/", $html, $match );
                    $result1 = array_unique( $match );
                    $count = count( $result1[0] );
                    preg_match_all( "/<div class=\"box-left\">(.+?)</", $html, $match5 );
                    $result5 = array_unique( $match5 );
                    preg_match_all( "/<img src=\"http:\\/\\/p1\\.pornhub\\.com\\/thumbs\\/000\\/(.+?)alt=/", $html, $match3 );
                    $result3 = array_unique( $match3 );
                    $count = count( $result3[0] );
                    $i = 0;
                    foreach ( $result1 as $val )
                    {
                        foreach ( $val as $item )
                        {
                            if ( $validcount < $amount )
                            {
                                $item = str_replace( "<a href = \"http://www.pornhub.com/view_video.php?viewkey=", "", $item );
                                $item = str_replace( "\"", "", $item );
                                if ( $item != "" )
                                {
                                    $query = "SELECT count(*) as total FROM videos WHERE pornhub='".mysql_real_escape_string( $item )."'";
                                    $executequery = $conn->execute( $query );
                                    $pornhubtotal = $executequery->fields[total] + 0;
                                    if ( $pornhubtotal == "0" )
                                    {
                                        $validcount++;
                                        $contin = "1";
                                        $titleandthumb = $result3[0][$i];
                                        preg_match_all( "/src=\"(.+?)\\.jpg/", $titleandthumb, $match6 );
                                        $result6 = array_unique( $match6 );
                                        $thumb = $result6[0][0];
                                        $thumb = str_replace( "src=\"", "", $thumb );
                                        $thumb = substr( $thumb, 0, 0 - 4 );
                                        $hubid = $thumb;
                                        $hubid = str_replace( "small", "", $hubid );
                                        $hubid = str_replace( "/", "", $hubid );
                                        $hubid = substr( $hubid, 0 - 6 );
                                        $hubid = intval( $hubid );
                                        preg_match_all( "/title=\"(.+?)\"/", $titleandthumb, $match7 );
                                        $result7 = array_unique( $match7 );
                                        $title = $result7[0][0];
                                        $title = str_replace( "title=\"", "", $title );
                                        $title = str_replace( "\"", "", $title );

                                        $rtime = $result5[0][$i];
                                        $rtime = str_replace( "<div class=\"box-left\">", "", $rtime );
                                        $rtime = str_replace( "<", "", $rtime );
                                        $pos = strrpos( $rtime, ":" );
                                        $mins = substr( $rtime, 0, $pos );
                                        $mins = intval( $mins );
                                        $secs = substr( $rtime, 0 - 2 );
                                        $secs = intval( $secs );
                                        $trtime = $mins * 60 + $secs;
                                        $approve_videos = $config[approve_videos];
                                        if ( $approve_videos == 1 )
                                        {
                                            $active = "active='0'";
                                        }
                                        else
                                        {
                                            $active = "active='1'";
                                        }
                                        $title = stripslashes( ereg_replace( "\"", "&#34;", $title ) );

                                        $thetitle = htmlentities( strip_tags( $title ), ENT_QUOTES, "UTF-8" );
                                        $thetags = htmlentities( strip_tags( $title ), ENT_QUOTES, "UTF-8" );
                                        $thedesc = htmlentities( strip_tags( $title ), ENT_QUOTES, "UTF-8" );
                                        $thecat = htmlentities( strip_tags( $_POST[category] ), ENT_QUOTES, "UTF-8" );
                                        $thepublic = intval( $_POST['public'] );
                                        $thepublic = htmlentities( strip_tags( $thepublic ), ENT_QUOTES, "UTF-8" );
                                        $theallowcomments = intval( $_POST['allowcomments'] );
                                        $theallowcomments = htmlentities( strip_tags( $theallowcomments ), ENT_QUOTES, "UTF-8" );
                                        $theallowratings = intval( $_POST['allowratings'] );
                                        $theallowratings = htmlentities( strip_tags( $theallowratings ), ENT_QUOTES, "UTF-8" );
                                        $theallowembeds = intval( $_POST['allowembeds'] );
                                        $theallowembeds = htmlentities( strip_tags( $theallowembeds ), ENT_QUOTES, "UTF-8" );
                                        $theallowdownloads = intval( $_POST['allowdownloads'] );
                                        $theallowdownloads = htmlentities( strip_tags( $theallowdownloads ), ENT_QUOTES, "UTF-8" );
                                        $themature = intval( $_POST['mature'] );
                                        $themature = htmlentities( strip_tags( $themature ), ENT_QUOTES, "UTF-8" );
                                        $query = "INSERT INTO videos SET USERID='{$_SESSION['USERID']}', title='".mysql_real_escape_string( $thetitle )."', description='".mysql_real_escape_string( $thedesc )."', tags='".mysql_real_escape_string( $thetags )."', categories='".mysql_real_escape_string( $thecat )."', filesize='10', public='".mysql_real_escape_string( $thepublic )."', time_added='".time( )."', date_added='".date( "Y-m-d" )."', {$active}, allowcomments='".mysql_real_escape_string( $theallowcomments )."', allowratings='".mysql_real_escape_string( $theallowratings )."', allowembeds='".mysql_real_escape_string( $theallowembeds )."', allowdownloads='".mysql_real_escape_string( $theallowdownloads )."', pornhub='".mysql_real_escape_string( $item )."', pornhub2='".mysql_real_escape_string( $hubid )."', runtime='".mysql_real_escape_string( $trtime )."', mature='".mysql_real_escape_string( $themature )."'";

                                        $conn->execute( $query ) or die(mysql_error()) ;
                                        //script crash here :  "  Error : MySQL server has gone away "
                                        $videoid = mysql_insert_id( );
                                        if ( is_numeric( $videoid ) && 0 < $videoid )
                                        {
                                            download_my_remote_thumbs( $thumb, $videoid );
                                            $addedvids++;
                                        }
                                    }
                                }
                            }
                            $i++;
                        }
                    }
                    $page++;
                }
            }

        }



    }
}
stemplate::assign( "pagetitle", $langph['1'] );
stemplate::assign( "error", $error );
stemplate::display( "header.tpl" );
stemplate::display( "pornhub.tpl" );
stemplate::display( "footer.tpl" );

?>



Don't Hate The Hacker,  Hate The Code


Cette discussion est classée dans : mysql, video, id, config, jpg


Répondre à ce message

Sujets en rapport avec ce message

problème de mise à jour de base de données [ par rildspael ] Ben en fait maintenant j'ai refait ce code, je me suis concentré, j'ai tout analysé mais rien ne marche encore et je ne comprends pas : le voici :Donc Afficher une ligne d'une table mysql [ par Alferox ] Bonjours,bon bin une question de base toute con.Je voudrais afficher uniquement la ligne qui port l'id 2 d'une table. Il n'y a pas plus simple que de mysql_fetch_row [ par angelique ] Bonjour,Après avoir rempli un formulaire, je voudrais utiliser les résultats d'une requête pour alimenter une autre table de ma base :$resultatid = my Pb Requet SQL [ par NoMitsu ] Voila je debute avec Php et MySql et j'ai quelque probleme pour faire marcher cette requet si quelqu'un pouvais me dire se qui cloche merci d'avance$c Sélectionner les lignes différentes entre deux tables [ par Mikemadest ] Bonjour,J'ai cherché sans trouver de réponse à mon problème,ce qui m'amène à vous poser cette question !D'avance je m'excuse si j'ai raté la solution Prob requete mysql [ par zzzzzz ] salut phpmyadmin me genere ca j'aimerai faire un champ qui s'auto incremente mais ca marche pas la requete de phpmyadmin:Erreurrequête SQL : ALTER T Recup de donnee dans MYSQL par ID du plus recent au plus ancien [ par jf2402 ] Salut,Je voudrais savoir comment récupérer mes enregistrements d'une table de ma base de donnée MYSQL en les classants du plus récent ID au plus ancie MySql config ? [ par holger ] J'auyrai souhaiter savoir si il était possible de fairetourner MySql sur un ordi tout pourrit :PC 200Mx 48Mo Ram Edo sous Windows 95Merci,Un lyonnais Mysql_insert_id() -> Problme -> A l'aide [ par Samiby ] J'ai une fonction d'exécution de requêtes avec déconnexion automatique (pour faire une connexion la moins lonque possible).function query_db($query) php/mysql erreur incomprehenssible <help> [ par luccs ] bonjour, voila j ais fait un petit script qui va gentilment afficher les details d un fournisseur (lister dans une box)mais voila il plante quand l id


Nos sponsors


Sondage...

Comparez les prix

CalendriCode

Février 2012
LMMJVSD
  12345
6789101112
13141516171819
20212223242526
272829    

Consulter la suite du CalendriCode

Photothèque

 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 3,307 sec (3)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales