LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   PHP Notice: Undefined offset: 1 in /var/opt/b.php on line 5 (https://www.linuxquestions.org/questions/linux-newbie-8/php-notice-undefined-offset-1-in-var-opt-b-php-on-line-5-a-4175463121/)

LnxGuru 05-23-2013 07:00 AM

PHP Notice: Undefined offset: 1 in /var/opt/b.php on line 5
 
can somebody help me with this ?

here is the script:

PHP Code:

<?php

require_once 'HTTP/Request2.php';

$request = new HTTP_Request2($url 'http://'.$argv[1].'/google'HTTP_Request2::METHOD_GET);
try {
    
$response $request->send();
    if (
200 == $response->getStatus()) {
        
$data $response->getBody();
        if (
preg_match('/ google /'$data)) {
                echo 
$url PHP_EOL;
        }
    } else {
        
$request = new HTTP_Request2($url 'https://'.$argv[1].'google'HTTP_Request2::METHOD_GET);
        
$request-> setConfig(array("ssl_verify_peer"=>FALSE,"ssl_verify_host"=>FALSE));
                
$response $request->send();
                if (
200 == $response->getStatus()) {
                        
$data $response->getBody();
                        if (
preg_match('/ google /'$data)) {
                                        echo 
$url PHP_EOL;
                        }
                }
        }
} catch (
HTTP_Request2_Exception $e) {
        
#echo 'Error: ' . $e->getMessage();
}


TB0ne 05-23-2013 09:56 AM

Quote:

Originally Posted by LnxGuru (Post 4957145)
can somebody help me with this ?
here is the script:
PHP Code:

$request = new HTTP_Request2($url 'http://'.$argv[1].'/google'HTTP_Request2::METHOD_GET); 


Well, the description clearly says the problem is on line 5. Did you try to LOOK at line 5????

Specifically, you need a space before and after the period (.) before and after the $argv[1].

NevemTeve 05-23-2013 10:08 AM

try isset($argv[1]) beforehand to verify if it has such element

TB0ne 05-23-2013 11:26 AM

Quote:

Originally Posted by NevemTeve (Post 4957244)
try isset($argv[1]) beforehand to verify if it has such element

I was going to ask the same thing, but assumed (dangerous, I know), that it was getting set by the "Request2.php" file.


All times are GMT -5. The time now is 06:44 PM.