Please help, i get this error when i run my script on my testing server

Notice: Undefined index: id in index.php on line 5

Notice: Undefined offset: 1 in index.php on line 8

but on my actual website, it displays a blank page, with the background colour, how do i solve these issues
Here is the code

<?php
  session_start();
  ob_start();
  include_once('lib/config.php');
  $id = explode('/',$_GET['id']);

  $_GET['id'] = $id[0];
  $_GET['p'] = $id[1];

 if(empty($_GET['id'])) $_GET['id']='twitter';
  include_once('lib/facebook/facebook.php');

Please how do i solve this

Instead of $_GET[] I think you mean $_REQUEST[].

Also, you don't want to assign something there so i'm not sure what you're trying to do with lines 7 and 8.

Also you're just getting a blank page because you're using ob_start() which is suppressing output but you're not flushing it out anywhere.

its actually a script someone wrote for me, users are suppose to be able to login with twitter. Finding it difficult to edit because i am actually new to php. Do i erase th ob_start line or what. how do i fix the problem exactly. Do not really understand you. Thanks for the reply

It seems that $_GET['id'] on line 5 expects the value as id=bar/foo, then this is rewritten by splitting the string to id and p keys on line 7 and 8.

@Donima4u you can replace this:

$id = explode('/',$_GET['id']);
$_GET['id'] = $id[0];
$_GET['p'] = $id[1];
if(empty($_GET['id'])) $_GET['id']='twitter';

With this:

$id = '';

if(array_key_exists('id', $_GET))
{
    $id = explode('/',$_GET['id']);
}

$_GET['id'] = array_key_exists(0, $id) ? $id[0] : 'twitter';
$_GET['p'] = array_key_exists(1, $id) ? $id[1] : ''; # set default here

Just be sure to set a default value for the p key. Bye.

Thanks for the reply, but i seem to get more error-where exactly do i set the default value of p, and the page still displays the background colour onli with the error message

These error are the same of the previous? Can you post the complete script and the exact errors?

These are the errors

Warning: array_key_exists() expects parameter 2 to be array, string given in index.php on line 10

Warning: array_key_exists() expects parameter 2 to be array, string given in index.php on line 11

Notice: Undefined variable: twitterObj in layout.php on line 59

Fatal error: Call to a member function setCallback() on a non-object in layout.php on line 59

Sorry my fault, change $id = ''; to $id = array(); and it should work:

$id = array();
if(array_key_exists('id', $_GET))
{
    $id = explode('/',$_GET['id']);
}
$_GET['id'] = array_key_exists(0, $id) ? $id[0] : 'twitter';
$_GET['p'] = array_key_exists(1, $id) ? $id[1] : ''; # set default here

Thanks alot, it works well on my testing server now, but still displays a blank page with just the background colour on my actual host server with godaddy. Wonder what the problem might be. Would really appreciate yur help. You have been really nice

Thanks

Without seeing the complete code it's difficult to suggest the correct solution. It can be related to Dani's suggestion, so:

Or your hosting plan does not have the buffering enabled. If you're in doubt first try to open the script with different browsers, otherwise try with a cURL request to see if you get something. In some cases the browsers do not output because there is not enough data in their buffers.

If you're still in doubt and you cannot check the error and access log files, then you may want to ask to the GoDaddy Support Team.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.