Board index   FAQ   Search  
Register  Login
Board index PHP PHP Installation

Problems

Forum for you who has PHP installation issues

Moderators: macek, egami, gesf

Problems

Postby fspilot » Sat Dec 06, 2003 1:41 pm

Hi,

Sorry if this has been asked / answered before,
I have just finised setting up a server on my PC
everything works and i have installed a PHPBB Forum and everything works ok their, but when i run a script i have created i get the following error

Notice: Undefined variable: ip in C:\http\Apache\Apache2\htdocs\functions.php on line 23

Notice: Use of undefined constant mysql - assumed 'mysql' in C:\http\Apache\Apache2\htdocs\functions.php on line 23

Notice: Use of undefined constant airline - assumed 'airline' in C:\http\Apache\Apache2\htdocs\functions.php on line 25

Warning: Cannot modify header information - headers already sent by (output started at C:\http\Apache\Apache2\htdocs\functions.php:8) in C:\http\Apache\Apache2\htdocs\pilots\verify.php on line 33

Warning: Unknown(): Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively. in Unknown on line 0


Any ideas why it doesnt work? or what i have to change?

Cheers!
fspilot
New php-forum User
New php-forum User
 
Posts: 26
Joined: Fri Jun 27, 2003 11:51 am
Location: Bath UK

Postby sigix » Sat Dec 06, 2003 11:41 pm

one problem is of register_global
please list the
php,apache,phpBB version
?
sigix
php-forum Active User
php-forum Active User
 
Posts: 364
Joined: Mon Jul 14, 2003 9:39 pm
Location: /Earth/Xion

Postby fspilot » Sun Dec 07, 2003 1:39 am

Apache: 2.0
PHP: 4.3.4
MySQL: 4.0.16

Thanks!
fspilot
New php-forum User
New php-forum User
 
Posts: 26
Joined: Fri Jun 27, 2003 11:51 am
Location: Bath UK

Postby fspilot » Sun Dec 07, 2003 11:32 am

Managed to fix it,

just turnt register_globals on and changed the error reporting level.

And all errors have gone and it all runs fine!
fspilot
New php-forum User
New php-forum User
 
Posts: 26
Joined: Fri Jun 27, 2003 11:51 am
Location: Bath UK

register globals...

Postby ruturajv » Sun Dec 07, 2003 9:01 pm

please always work with register globals OFF!!!! :!:
User avatar
ruturajv
php-forum Super User
php-forum Super User
 
Posts: 1280
Joined: Sat Mar 22, 2003 9:42 am
Location: Mumbai, India

Postby fspilot » Mon Dec 08, 2003 3:02 pm

what about if i want to use sessions then?
I dont really understand that bit because i guess my old hosting company had it turnt off and the sessions worked fine but they wouldnt work on my own server with register_globals turnt off?? :?
fspilot
New php-forum User
New php-forum User
 
Posts: 26
Joined: Fri Jun 27, 2003 11:51 am
Location: Bath UK

Postby swirlee » Mon Dec 08, 2003 5:51 pm

This isn't a sessions problem. If you look closely, all of your errors (excepting the last one, which is just a symptom of the first two) are just Notices. They won't stop your script from executing, and they won't show up on most configurations.

Notice: Undefined variable: ip in C:\http\Apache\Apache2\htdocs\functions.php on line 23

Though you haven't shown us any code, this probably means that you're trying to access or alter a variable ($ip) that hasn't been initialized. Such variables simply evaluate to 0 in PHP. Though it's good programming practice to make sure all of your variables are initialized (e.g. make sure $i has a value before you increment it with ++, or make sure $s has a value before you try to append something to it with .=), PHP knows how to deal with these problems and your script will execute just fine.

Notice: Use of undefined constant mysql - assumed 'mysql' in C:\http\Apache\Apache2\htdocs\functions.php on line 23

Again, since I can't see your code, this is tricky, but I'm 99% sure that you're trying to access an array index called 'mysql', but without quotes, e.g.:

Code: Select all
<?php
// WRONG:
$arr = array('mysql' => 1);
echo $arr[mysql];
/* output:
      1
*/

// RIGHT:
echo $arr['mysql'];
/* output:
      1
*/
?>


As you can see, both of them output correctly, but the second one is the only one that's syntactically correct. Read the Arrays documentation for more information (see "Array Do's and Don'ts"). On most machines you won't even get an error message.

So, why are you getting these messages? Because in your configuration file, there's a section called "Error handling and logging" in which you can set the level of error reporting. You have it set to report Notices, which is why these messages are appearing. Turn it off if you want, but the wiser thing would be to fix your scripts.
User avatar
swirlee
Moderator
Moderator
 
Posts: 2272
Joined: Sat Jul 05, 2003 1:18 pm
Location: A bunk in the back

Postby fspilot » Tue Dec 09, 2003 1:38 am

nope lol

The script i was using was working fine on a server beforehand, then i set up my own server and got the error messages,

Warning: Unknown(): Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively. in Unknown on line 0

This is the part that wouldnt go away unless i changed register_globals.

All of my varibles also are set, im really confused as the script worked fine before and if i change register_globals it works fine now,
otherwise it doesnt reckonise (sp?) the sessions.

Please Help im really lost :(
fspilot
New php-forum User
New php-forum User
 
Posts: 26
Joined: Fri Jun 27, 2003 11:51 am
Location: Bath UK

Postby swirlee » Tue Dec 09, 2003 9:00 am

We're just as lost as you are until you show us some code.
User avatar
swirlee
Moderator
Moderator
 
Posts: 2272
Joined: Sat Jul 05, 2003 1:18 pm
Location: A bunk in the back

Postby fspilot » Tue Dec 09, 2003 9:46 am

Code: Select all
<?
session_start();
session_register('name');
session_register('login');
session_register('pid');

include "../includes.inc.php";
connect();
$id = $_POST['id'];
$password = $_POST['password'];
$query = "SELECT pid FROM roster WHERE pid='$id'";
$result = mysql_query($query)
   or die (mysql_error());
$num = mysql_num_rows($result);
if ($num == 1)
{
   $query2 = "SELECT pid FROM roster WHERE pid = '$id' AND password = '$password'";
   $result2 = mysql_query($query2)
      or die(mysql_error());
   $num2 = mysql_num_rows($result2);
   if ($num2 > 0)
      {
      $query3 = "UPDATE roster set last_login = NOW() WHERE pid = '$id'";
      $result3 = mysql_query($query3)
         or die(mysql_error());
      $query4 = "SELECT * FROM roster WHERE pid='$id'";
      $result4 = mysql_query($query4)
         or die(mysql_error());
      while ($row = mysql_fetch_array($result4)) {
         $name = $row['name'];
         $login = "yes";
         $pid = $row['pid'];
         header("Location: index.php");
         }
      }
   else
      {
      $message = "You entered an incorrect username or password please try again!";
      include "login.php";
      }
   }
elseif ($num == 0)
{
$message = "You entered an incorrect username or password please try again!";
include "login.php";
}
?>


Here is the verify.php file
fspilot
New php-forum User
New php-forum User
 
Posts: 26
Joined: Fri Jun 27, 2003 11:51 am
Location: Bath UK

Postby swirlee » Tue Dec 09, 2003 10:25 am

Oh. Well, that's easy. Just use $_SESSION['name'], $_SESSION['login'], and $_SESSION['pid'].
User avatar
swirlee
Moderator
Moderator
 
Posts: 2272
Joined: Sat Jul 05, 2003 1:18 pm
Location: A bunk in the back


Return to PHP Installation

Who is online

Users browsing this forum: No registered users and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.