Visualizzazione dei risultati da 1 a 5 su 5

Discussione: Problemi php

  1. #1

    Problemi php

    Salve ragazzi un un file index.php che va a richiamare altri file sempre in php

    eccovi il sorgente

    codice:
    <?php
    ob_start();
    error_reporting(E_ALL);
    session_start();
    $_SESSION['user_logged'] = false;
    
    require_once('config.php');
    
    
    $smarty->display('head.tpl');
    
    $smarty->display('head_menu.tpl');
    $smarty->display('search_form.tpl');
    
    require_once('app-modules.php');
    
    ?>
    
    
    </div>
    <?php $smarty->display('footer.tpl'); ?>
    La domanda che mi pongo come mai mi visualizza i seguenti errori?

    codice:
    Notice: A session had already been started - ignoring session_start() in /membri/trest/app-load.php on line 2
    
    Notice: Undefined index: lang in /membri/trest/app-load.php on line 6
    
    Notice: Undefined index: lang in /membri/trest/app-load.php on line 9
    
    Notice: Undefined index: lang in /membri/trest/app-load.php on line 12
    
    Notice: Undefined index: lang in /membri/trest/app-load.php on line 15
    
    Notice: Undefined index: lang in /membri/trest/app-load.php on line 18
    
    Notice: Undefined index: lang in /membri/trest/app-load.php on line 21
    
    Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /membri/trest/class/youtube.class.php on line 21
    P.S. ho anche un file config.php dipende da quello?

  2. #2
    gli errori da te postati ti dicono già tutto quello che occorre per rimediare

    Notice: A session had already been started - ignoring session_start() in /membri/trest/app-load.php on line 2

    hai messo due volte session_start(); la seconda è stata ignorata

    Notice: Undefined index: lang in /membri/trest/app-load.php on line 9

    stai cercando di usare un indice di un array che non esiste tipo $ar["lang"]... ricontrolla alla linea 9

    Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /membri/trest/class/youtube.class.php on line 21

    errore di scrittura del file php, gli hai dato una stringa quando non la vuole.


    inoltre gli errori sono tutti su due pagine di nome app-load.php e youtube.class.php che non hai neanche incluso nel codice...la prossima volta postalo tutto!
    Perchè essere stupidi non è una menomazione ma un diritto di tutti!!!

  3. #3
    Ti suggerisco di leggere questo articolo:

    Notice: Undefined variable / index / offset

    Per quanto riguarda "session had already been started", il messaggio d'errore è piuttosto esplicito. Stai richiamando due volte session_start(). La seconda volta nel file "in /membri/trest/app-load.php on line 2".

  4. #4
    Grazie per la tua risposta :-) e per la tua velocità

    Questo è il file app-load.php
    codice:
    <?php
    session_start();
    if(empty($_SESSION['language'])) {
    $_SESSION['language'] = 'en';
    }
    if($_GET['lang'] == "en") {
    $_SESSION['language'] = 'en';
    }
    if($_GET['lang'] == "pl") {
    $_SESSION['language'] = 'pl';
    }
    if($_GET['lang'] == "cs") {
    $_SESSION['language'] = 'cs';
    }
    if($_GET['lang'] == "ro") {
    $_SESSION['language'] = 'ro';
    }
    if($_GET['lang'] == "ru") {
    $_SESSION['language'] = 'ru';
    }
    if($_GET['lang'] == "de") {
    $_SESSION['language'] = 'de';
    }
    require_once('languages/'.$_SESSION['language'].'.php');
    
    require('libs/Smarty.class.php');
    require_once('class/wrzuta.class.php');
    require_once('class/youtube.class.php');
    require_once('class/radar.class.php');
    require_once('class/allegro.class.php');
    require_once('class/wikipedia.class.php');
    require_once('class/lyrics.class.php');
    require_once('class/torrents.class.php');
    require_once('class/pornhub.class.php');
    
    
    require_once('class/images.google.class.php');
    
    require_once('class/pager.class.php');
    require_once('class/functions.class.php');
    
    $smarty = new Smarty;
    $torrents = new torrents;
    $images = new images;
    $radar = new radar;
    $wrzuta = new wrzuta;
    $youtube = new video;
    $allegro = new allegro;
    $wikipedia = new wikipedia('http://'.$_SESSION['language'].'.wikipedia.org');
    $lyrics = new lyrics;
    $xxx = new xxx;
    
    $f = new functions;
    $pager = new pager;
    
    ?>
    e questo il file youtube.class.php
    codice:
    <?php
    /* =============================================================================
     * Copyright 2005-08
     * commenti
     *
     * comenti
     *
     * commenti
     * 
     * commenti
     *
     * commenti
     * =============================================================================
    */
    define('API_KEY', 'ARgbYoNTCbs');
    define('API_URL', 'http://www.youtube.com/');
    define('API_REST_CALL', API_URL . 'api2_rest?');
    define('API_XMLRPC_CALL', API_URL . 'api2_xmlrpc?');
    define('BY_TAG', 'list_by_tag');
    class youtube {
    	public $xml, $config = array(), $api_call, $return, $tag, $errors;
    	public function __construct($api_key = API_KEY, $page = 1, $per_page = 25) {
    		youtube::set('api_key', API_KEY);
    		youtube::set('page', $page);
    		youtube::set('per_page', $per_page);
    		youtube::modify_call(API_REST_CALL . 'method=youtube.');
    	}
    
    	function xml_to_array($xml) {
    		$fils = 0;
    		$tab = false;
    		$array = array();
    
    		foreach($xml->children() as $key => $value) {
    			$child = youtube::xml_to_array($value);
    
    			//To deal with the attributes
    			//foreach ($node->attributes() as $ak => $av) {
    			//	$child[$ak] = (string)$av;
    			//}
    			//Let see if the new child is not in the array
    			if ($tab == false && in_array($key, array_keys($array))) {
    				//If this element is already in the array we will create an indexed array
    				$tmp = $array[$key];
    				$array[$key] = NULL;
    				$array[$key][] = $tmp;
    				$array[$key][] = $child;
    				$tab = true;
    			} elseif($tab == true) {
    				//Add an element in an existing array
    				$array[$key][] = $child;
    			} else {
    				//Add a simple element
    				$array[$key] = $child;
    			}
    			$fils++;
    		}
    
    		if($fils==0) {
    			return (string)$xml;
    		}
    		return $array;
    	}
    
    	// SET A CONFIG VARIABLE
    	public function set($item, $value) {
    		$this->config[$item] = $value;
    	}
    
    	// ACCESS CONFIG
    	public function config($item) {
    		return $this->config[$item];
    	}
    
    	// MODIFY THE CALL CLASS PROPERTY
    	public function modify_call($params) {
    		$this->api_call .= $params;
    	}
    
    	// ECHO THE CALL FOR DEBUGGING
    	public function return_call() {
    		return $this->api_call;
    	}
    
    	// YOUTUBE VIDEO METHODS
    	public function videos($data = '', $method = BY_TAG) {
    		//---------------------------------------------//
    		$this->api_call .= 'videos.'; ///////////////////////
    		//---------------------------------------------//
    		switch ($method) {
    			case BY_TAG:
    				if (isset($_GET['video'])) {
    					$_GET['video'] = str_replace(' ', '+', $_GET['video']);
    					$this->tag = '&tag=' . $_GET['video'];
    				} else {
    					$this->tag = '&tag='. $data;
    				}
    				youtube::modify_call($method . '&dev_id=' . $this->config['api_key'] . $this->tag);
    				break;
    
    			default:
    				return 'Tags.';
    				break;
    		}
    
    		// CALL DISPLAY
    		return youtube::display();
    	}
    
    	public function tags_for_video($tags) {
    		$tag_links = '';
    
    		// explode
    		$x = explode(' ', $tags);
    		if (count($x) > 0) {
    			foreach ($x as $k => $v) {
    				$tag_links .= "<a href=\"{$_SERVER['PHP_SELF']}?tag=$v\">$v</a> ";
    			}
    		} else { 
    			$tag_links = "<a href=\"{$_SERVER['PHP_SELF']}?tag=mutemath\">mutemath</a>";
    		}
    		return $tag_links;
    	}
    
    	// DISPLAY RESULTS
    	public function display() {
    		// CHECK FOR A NEW PAGE & PER PAGE
    		if (isset($_GET['page'])) {
    			youtube::set('page', $_GET['page']);
    		}
    		if (isset($_GET['per_page'])) {
    			youtube::set('per_page', $_GET['per_page']);
    		}
    
    		// per page, page, prev, next
    		// total videos, total pages
    		youtube::modify_call('&page=' . youtube::config('page') . '&per_page=' . youtube::config('per_page'));
    
    		// SEND REQUEST
    		$this->return = file_get_contents(youtube::return_call());
    		$this->xml = new SimpleXMLElement($this->return);
    		$this->xml = youtube::xml_to_array($this->xml);
    
    		// CHECK IF THEY'RE ASKING FOR A VIDEO ID
    		if (isset($_GET['video_id'])) {
    			define('YOUTUBE_VIDEO_ID', $_GET['video_id']);
    			
    			// loop through videos to get videos index
    			foreach ($this->xml['video_list']['video'] as $indx => $array) {
    				if ($array['id'] == $_GET['video_id']) {
    					$index = $indx;
    					echo $index;
    					break;
    				} else {
    					$index = '';
    				}
    			}
    
    			// define index
    			define('YOUTUBE_VIDEO_INDEX', $index);
    		} else {
    			define('YOUTUBE_VIDEO_ID', $this->xml['video_list']['video'][0]['id']);
    			define('YOUTUBE_VIDEO_INDEX', 0);
    		}
    
    		//////////////////////////////////////////
    		// CREATE DISPLAY CONSTANTS //
    		/////////////////////////////////////////
    		define('YOUTUBE_PAGE', youtube::config('page'));
    		define('YOUTUBE_PER_PAGE', youtube::config('per_page'));
    		$prev = (youtube::config('page') - 1 == 0) ? 1 : youtube::config('page') - 1;
    		define('YOUTUBE_PREV_PAGE', $prev . $this->tag);
    		define('YOUTUBE_NEXT_PAGE', youtube::config('page') + 1 . $this->tag);
    		define('YOUTUBE_TOTAL_VIDEOS', $this->xml['video_list']['total']);
    		define('YOUTUBE_TOTAL_PAGES', ceil($this->xml['video_list']['total'] / youtube::config('per_page')));
    
    		// CONVERT FROM SIMPLEXML OBJECT TO ARRAY
    		return $this->xml;
    	}
    }
    
    class video {
    
    function wyniki($query, $p) {
    $api = new youtube();
    $api->set('per_page', 16);
    $api->set('page', $p);
    $res = $api->videos(urlencode($query));
    $video_list = $res['video_list']['video'];
    require_once('class/functions.class.php');
    $f = new functions;
    
    	foreach ($video_list as $k => $v) {
    	$this->wynik[] = array(
    	'title' => $v['title'],
    	'id' => $v['id'],
    	'thumb' => $v['thumbnail_url'],
    	'desc' => $v['description'],
    	'author' => $v['author'],
    	'tags' => $v['tags'],
    	'rating' => $v['rating_avg'],
    	'views' => $v['view_count'],
    	'time' => $v['length_seconds'],
    	'link' => $f->usun_znaki($v['title']),
    );
    }
    
    return $this->wynik;
    
    }
    
    		function get_link($id) {
    			if($_SESSION['language'] == "pl") {
    			$langz = 'pl.';
    		}
    		else {
    		$langz = '';
    		}
    			$youtube_video_id = $id;
    			$open = file_get_contents('http://'.$langz.'youtube.com/watch?v='.$youtube_video_id.'');
    			preg_match_all('/"video_id": "(.*)", "l": (.*), "sk": "(.*)"/', $open, $id); // get video id
    			preg_match_all('/"l": (.*), "sk": "(.*)"/', $open, $le); // get "l" var
    			preg_match_all('/"t": "(.*)", "(.*)": "(.*)", "(.*)": "(.*)"/ismU', $open, $te); // get "t" vars
    			preg_match_all('#<title>YouTube - (.*)<\/title>#ismU', $open, $this->title);
    			preg_match_all('#<td>(.*): <span class="watch-stat">(.*)<\/span><\/td>#ismU', $open, $this->stats);
    			preg_match_all('#<div  class="watch-video-desc">\s+<span >(.*)<\/span>\s+<\/div>#ismU', $open, $this->desc);
    			$this->desc = $this->desc[1][0];
    			$this->stats = $this->stats[2][0];
    			$this->title = $this->title[1][0];
    			$this->t = $te[1][0];
    			$this->return = array('t' => $this->t, 'title' => $this->title, 'added' => $this->stats, 'desc' => $this->desc, 'id' => $this->id);
    			return $this->return;
    	}
    
    
    function records_count($q) {
    
    $this->q = urlencode($q);
    $this->url = 'http://youtube.com/results?search_query='.$this->q;
    $this->content = file_get_contents($this->url);
    
    preg_match_all('#of about (.*)#ismU', $this->content, $this->results);
    
    $this->results = $this->results[1][0];
    
    $this->results = str_replace(',', '', $this->results);
    
    return $this->results;
    
    }
    
    }
    ?>

    PS se levo il session start al file app.load.php mi da questo errore

    codice:
    Fatal error: Call to undefined method: stdClass->assign() in /membri/trest/config.php on line 7
    questo è il file config.php

    codice:
    <?php
    require('app-load.php');
    
    
    $smarty->debugging = false;	// debugging false = off, true = on
    $smarty->caching = false; 	// caching = false = off, true = on
    $smarty->assign('lang', $lang);
    
    class configuration {
    
     function cfg() {
    	$cfg = array(
    	'img_dir' => 'public/title_images/',
    	'site_url' => 'http://www.mysite.com/', 
    );
    
    return $cfg;
    
    }
    
    
    }
    
    $cfg = new configuration;
    
    $smarty->assign('cfg', $cfg->cfg());
    
    if(empty($_GET['slowo']) && empty($_GET['akcja'])) {
    
    $smarty->assign('title', 'KatalogMP3.eu');
    
    } else {
    
    $smarty->assign('title', $f->dynamic_title($_GET['slowo']));
    
    }
    
    if($_GET['aplikacja'] == "price" || $_GET['aplikacja'] == "auctions" && $_GET['aplikacja'] == "lyrics") {
    
    $smarty->assign('title', 'KatalogMP3.eu'); // default site title
    
    }
    
    if($_GET['akcja'] == "show" && $_GET['aplikacja'] == "mp3") {
    
    $mp3_info = $wrzuta->get_file_info($_GET['mp3_id']);
    $title = $mp3_info['title'];
    
    $title .= ' MP3 ' . $lang['listen_and_download'];
    
    $smarty->assign('title', $title);
    
    }
    
    if($_GET['akcja'] == "show" && $_GET['aplikacja'] == "video") {
    
    $info = $youtube->get_link($_GET['video_id']);
    $title = $info['title'];
    
    $title .= ' Video ' . $lang['watch_and_download'];
    
    $smarty->assign('title', $title);
    
    }
    
    ?>
    premetto che di php ci capisco ben poco.. mi daresti qualke atra dritta per favore..?

    Grazie in anticipo

  5. #5
    Mi date una mano per favore....

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.