Anyone have a clue why i am getting this error ?

Discussion in 'PHP' started by cybercool, Feb 22, 2006.

  1. #1
    "Notice: Only variable references should be returned by reference "

    i have set debugging to false.. but still getting this error.
     
    cybercool, Feb 22, 2006 IP
  2. sarahk

    sarahk iTamer Staff

    Messages:
    28,828
    Likes Received:
    4,541
    Best Answers:
    123
    Trophy Points:
    665
    #2
    Is that PHP5?
     
    sarahk, Feb 23, 2006 IP
  3. echelon

    echelon Peon

    Messages:
    28
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Can you give me some sample code? It could be anything.
     
    echelon, Feb 23, 2006 IP
  4. cybercool

    cybercool Peon

    Messages:
    128
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #4
    My server is running the latest version of PHP

    here is the code ... the error produced :


    Notice: Only variable references should be returned by reference in /hsphere/local/home/..../....../...../inc/database.php on line 47


    <?php
    /******************************************************************************
    * File: database.php
    * Description: database class for MySQL
    * Author: Thorsten Rinne
    * Portions of this Code is based on work by
    * Meikel Katzengreis
    * Date: 2003-02-24
    * Last Update: 2003-11-20
    * Copyright: (c) 2001-2003 Thorsten Rinne
    *
    * The contents of this file are subject to the Mozilla Public License
    * Version 1.1 (the "License"); you may not use this file except in
    * compliance with the License. You may obtain a copy of the License at
    * http://www.mozilla.org/MPL/
    *
    * Software distributed under the License is distributed on an "AS IS"
    * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
    * License for the specific language governing rights and limitations
    * under the License.
    ******************************************************************************/

    class db_mysql {

    var $conn = false;
    var $queries = 0;
    var $sqllog = "";

    // connect to server and select database
    function &connect ($host, $user, $passwd, $db)
    {
    $this->conn = @mysql_connect($host,$user,$passwd);
    if (empty($db) OR $this->conn == false)
    {
    print "<p align=\"center\">The connection to the MySQL server could not be established.</p>\n";
    print "<p align=\"center\">The error message of the MySQL server:<br />".mysql_error()."</p>\n";
    return false;
    }


    $db_selected = mysql_select_db($db, $this->conn);
    if (!$db_selected)
    {
    die ('Can\'t use Database : ' . mysql_error());
    }

    } <--------------- THIS IS LINE 47...WHERE ITS SAYING THERE IS AN ERROR

    // send a query
    function &query ($query) {
    $this->sqllog .= $query."<br>\n";
    $this->queries++;
    $ret = @mysql_query($query, $this->conn);
    return $ret;
    }
    // fetch a result row as an object
    function &fetch_object ($result) {
    $ret = @mysql_fetch_object($result);
    return $ret;
    }
    // fetch a result row
    function &fetch_row ($result) {
    $ret = @mysql_fetch_row($result);
    return $ret;
    }
    // fetch a row as an array
    function &fetch_assoc ($result) {
    $ret = @mysql_fetch_assoc($result);
    return $ret;
    }
    // fetch a result row
    function &num_rows ($result) {
    $ret = @mysql_num_rows($result);
    return $ret;
    }
    // get the last id
    function &insert_id () {
    $ret = @mysql_insert_id($this->conn);
    return $ret;
    }
    // prints the count of queries
    function &countqueries() {
    $ret = $this->queries;
    return $ret;
    }
    // prints the count of queries
    function &sqllog() {
    $ret = $this->sqllog;
    return $ret;
    }
    // closes a connection
    function &dbclose() {
    $ret = @mysql_close($this->conn);
    return $ret;
    }
    }

    ?>
     
    cybercool, Feb 23, 2006 IP
  5. echelon

    echelon Peon

    Messages:
    28
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    // connect to server and select database
    function &connect ($host, $user, $passwd, $db)

    There shouldn't be an & in front of the connect() method.

    Use:

    function connect ($host, $user, $passwd, $db)
     
    echelon, Feb 25, 2006 IP