Page 1 of 1

PHP Warnings how can I fix it

Posted: Tue Jun 27, 2006 9:00 am
by andy84
Hello my problems are here http://websign.webd.pl/wiki/ if you will run it at the bottom you will find bunch of PHP Warnings.

As I notice all of them are ending wiht ' Notice[8]: Only variables should be assigned by reference ' - I was trying to find what is that mean (maby not enough good)

this is an example of error: " lib/WikiUser.php:59: Notice[8]: Only variables should be assigned by reference "

and this is the line 59 of WikiUser.php file:

Code: Select all

$this->_dbi = &$this->_request->getDbh();
The code is OK i belicve as you can notice this is wiki code

it is installed on PHP 5.1.4
MySQL version 4.1.13

but I have to use index.php4 - this scripts when they run on version 5.1.4 they have basic error

this is the error when using 5.1.4 : lib/main.php:20: Fatal[2048]: Assigning the return value of new by reference is deprecated

line 20 from main.php file

Code: Select all

$this->_dbsession = & new DB_Session($this->getDbh(),

this info you can get from http://websign.webd.pl/wiki/test.php

thank you for your help

Posted: Tue Jun 27, 2006 9:17 am
by feyd
PHP5 handles objects differently than PHP4. In 5, objects default to passing by reference. Therefore you will get these warnings when objects are being doubly passed by reference. Try removing the ampersands where these warnings are showing.

Posted: Tue Jun 27, 2006 9:25 am
by andy84
feyd wrote:PHP5 handles objects differently than PHP4. In 5, objects default to passing by reference. Therefore you will get these warnings when objects are being doubly passed by reference. Try removing the ampersands where these warnings are showing.

Code: Select all

function &query($query, $params = array()) {
        if (sizeof($params) > 0) {
            $sth = $this->prepare($query);
            if (DB::isError($sth)) {
                return $sth;
            }
            return $this->execute($sth, $params);
        } else {
            $result = $this->simpleQuery($query);
            if (DB::isError($result) || $result === DB_OK) {
                return $result;
            } else {
     741line: ->           return new DB_result($this, $result);
            }
        }
    }
Im not lazy but look on this 741 line above it dont have any of '&' but it is still listed
"lib/pear/DB/common.php:741: Notice[8]: Only variable references should be returned by reference"

By the way I was trying to remove it for just one of the files ( only from the place which was listed ) it is still on the list of errors

it is realy hard to understand why and how to fix it ;/

Posted: Tue Jun 27, 2006 10:15 am
by RobertGonzalez
There is an ampersand just before the function name?!?!?

Code: Select all

<?php
function &query($query, $params = array()) { 
?>

Posted: Wed Jun 28, 2006 5:49 am
by andy84
Everah wrote:There is an ampersand just before the function name?!?!?

Code: Select all

<?php
function &query($query, $params = array()) { 
?>

Just two thinks:

1. I deleted what you said ( it didn't help )
2. maby you shloud read what was written before - I was pointed to line 741 by the error and you are telling me to erase it from line 729 what for )

the think is that this error is form main page if I will start changing something using edit ( wiki option ) this errors will start changin also ;/

PHP Warnings

lib/pear/DB/common.php:741: Notice[8]: Only variable references should be returned by reference

lib/WikiUser.php:59: Notice[8]: Only variables should be assigned by reference

lib/pear/DB/common.php:741: Notice[8]: Only variable references should be returned by reference

lib/pear/DB/common.php:741: Notice[8]: Only variable references should be returned by reference

lib/pear/DB/common.php:741: Notice[8]: Only variable references should be returned by reference

lib/Template.php:112: Notice[8]: Only variables should be assigned by reference

lib/Template.php:114: Notice[8]: Only variables should be assigned by reference

lib/Template.php (In template 'html'):112: Notice[8]: Only variables should be assigned by reference

lib/Template.php (In template 'html'):114: Notice[8]: Only variables should be assigned by reference

lib/Template.php (In template 'html'):112: Notice[8]: Only variables should be assigned by reference

lib/Template.php (In template 'html'):114: Notice[8]: Only variables should be assigned by reference

lib/Template.php (In template 'body') (In template 'html'):112: Notice[8]: Only variables should be assigned by reference

lib/Template.php (In template 'body') (In template 'html'):114: Notice[8]: Only variables should be assigned by reference

lib/Template.php (In template 'top') (In template 'body') (In template 'html'):112: Notice[8]: Only variables should be assigned by reference

lib/Template.php (In template 'top') (In template 'body') (In template 'html'):114: Notice[8]: Only variables should be assigned by reference

lib/pear/DB/common.php (In template 'navbar') (In template 'top') (In template 'body') (In template 'html'):741: Notice[8]: Only variable references should be returned by reference

lib/Template.php (In template 'body') (In template 'html'):112: Notice[8]: Only variables should be assigned by reference

lib/Template.php (In template 'body') (In template 'html'):114: Notice[8]: Only variables should be assigned by reference

lib/pear/DB/common.php (In template 'browse') (In template 'body') (In template 'html'):741: Notice[8]: Only variable references should be returned by reference

lib/pear/DB/common.php (In template 'browse') (In template 'body') (In template 'html'):741: Notice[8]: Only variable references should be returned by reference

lib/pear/DB/common.php (In template 'browse') (In template 'body') (In template 'html'):741: Notice[8]: Only variable references should be returned by reference

lib/pear/DB/common.php (In template 'browse') (In template 'body') (In template 'html'):741: Notice[8]: Only variable references should be returned by reference

lib/pear/DB/common.php (In template 'browse') (In template 'body') (In template 'html'):741: Notice[8]: Only variable references should be returned by reference

lib/pear/DB/common.php (In template 'browse') (In template 'body') (In template 'html'):741: Notice[8]: Only variable references should be returned by reference

lib/pear/DB/common.php (In template 'browse') (In template 'body') (In template 'html'):741: Notice[8]: Only variable references should be returned by reference

lib/pear/DB/common.php (In template 'browse') (In template 'body') (In template 'html'):741: Notice[8]: Only variable references should be returned by reference

lib/pear/DB/common.php (In template 'browse') (In template 'body') (In template 'html'):741: Notice[8]: Only variable references should be returned by reference

lib/pear/DB/common.php (In template 'browse') (In template 'body') (In template 'html'):741: Notice[8]: Only variable references should be returned by reference

lib/Template.php (In template 'browse') (In template 'body') (In template 'html'):112: Notice[8]: Only variables should be assigned by reference

lib/Template.php (In template 'browse') (In template 'body') (In template 'html'):114: Notice[8]: Only variables should be assigned by reference

lib/Template.php (In template 'browse-footer') (In template 'browse') (In template 'body') (In template 'html'):112: Notice[8]: Only variables should be assigned by reference

lib/Template.php (In template 'browse-footer') (In template 'browse') (In template 'body') (In template 'html'):114: Notice[8]: Only variables should be assigned by reference

lib/Template.php (In template 'actionbar') (In template 'browse-footer') (In template 'browse') (In template 'body') (In template 'html'):112: Notice[8]: Only variables should be assigned by reference

lib/Template.php (In template 'actionbar') (In template 'browse-footer') (In template 'browse') (In template 'body') (In template 'html'):114: Notice[8]: Only variables should be assigned by reference

lib/Template.php (In template 'body') (In template 'html'):112: Notice[8]: Only variables should be assigned by reference

lib/Template.php (In template 'body') (In template 'html'):114: Notice[8]: Only variables should be assigned by reference

Posted: Wed Jun 28, 2006 5:53 am
by Chris Corbyn
Everah's post was actually helpful....

The error you're seeing is because in PHP5 you can only return variables by reference. That code tries to return an object before storing it in a variable first which only works in PHP4.

Posted: Wed Jun 28, 2006 7:42 am
by andy84
d11wtq wrote:Everah's post was actually helpful....

The error you're seeing is because in PHP5 you can only return variables by reference. That code tries to return an object before storing it in a variable first which only works in PHP4.
At this stage Im using PHP4 my hosting provider written down in faq how to use PHP 5.1.4 so I did that just for update than nothing was working so they advice me to change file name to index.php4 so I will be using version 4 again.

As I can notice when Im usign v4 the web is working with this error before the update was this same

when Im using v 5 it's like you are saing and I defenatly agree with you
The error you're seeing is because in PHP5 you can only return variables by reference. That code tries to return an object before storing it in a variable first which only works in PHP4.
I will try to update the wiki to the newest version maby that gona help me I will try it in the evening thanks for your posts if I will still have some problems I will let you know