LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-23-2013, 07:00 AM   #1
LnxGuru
LQ Newbie
 
Registered: Mar 2012
Posts: 3

Rep: Reputation: Disabled
Unhappy 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();
}
 
Old 05-23-2013, 09:56 AM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 17,948

Rep: Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693
Quote:
Originally Posted by LnxGuru View Post
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].
 
Old 05-23-2013, 10:08 AM   #3
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 2,957

Rep: Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845
try isset($argv[1]) beforehand to verify if it has such element
 
1 members found this post helpful.
Old 05-23-2013, 11:26 AM   #4
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 17,948

Rep: Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693Reputation: 3693
Quote:
Originally Posted by NevemTeve View Post
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP gearman undefined symbol: zend_new_interned_string in Unknown on line 0 flyer103 Programming 3 04-23-2012 09:01 AM
PHP Notice: Trying to get property of non-object in /var/www/localhost/htdocs/intrane prayag_pjs Linux - Software 0 12-07-2011 03:10 AM
php undefined offset eoc92866 Programming 5 12-10-2010 04:19 PM
Notice: Uninitialized string offset: 1 in [PHP] TheIndependentAquarius Programming 8 11-10-2010 11:09 PM
Fatal Error - Call to undefined function : pg_pconnect() in filename.php on line xx mwpeng Linux - Newbie 1 02-26-2005 09:57 AM


All times are GMT -5. The time now is 12:40 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration