reference errors from PHP 4.4.0 update
Posted: Sun Jun 04, 2006 11:36 am
**********UPDATE***********************
Ok... so I was able to fix all of the errors by deleting the ampersand except one. The one that is still all over the site is
Here is the entire database.php file in case it helps. Also, it seems like the other lines of code are very similar to line 26 and if it is causing an error, shouldn't the others be as well?
**********ORIGINAL POST*****************
So I've researched this to the best of my ability online. As far as I can tell, what has happened is that my webhost updated PHP to 4.4.2 and it created a number of variable reference errors on my site.
Here is my site: http://www.weddingwebsites.com
The errors I am getting are like this:
Notice: Only variables should be assigned by reference in /home/wedweb/public_html/library/review-functions.php on line 210
Notice: Only variable references should be returned by reference in /home/wedweb/public_html/library/database.php on line 26
Notice: Only variables should be assigned by reference in /home/wedweb/public_html/library/review-functions.php on line 219
Notice: Only variables should be assigned by reference in /home/wedweb/public_html/library/compairesite-functions.php on line 61
The errors seem to be in only about 5 or 6 php files.
I found this after doing a search on the error:
http://codex.gallery2.org/index.php/Gal ... s_wrong.3F
I wrote my localhost and he responded with this:
I also found this resource http://www.simplemachines.org/community ... rdseen#new which recommended the ampersands be removed. That would seem to apply to 3 of the 4 above, but doesn't help me with the most prevalent error (the second one).
So, I guess I'd like to know if I could just edit these code lines myself or if it's going to take siginificant rewriting of the code?
Thanks in advance for the help![/quote]
Ok... so I was able to fix all of the errors by deleting the ampersand except one. The one that is still all over the site is
This is line 26:Notice: Only variable references should be returned by reference in /home/wedweb/public_html/library/database.php on line 26
Code: Select all
return mysql_fetch_assoc($result);Code: Select all
<?php
require_once 'config.php';
$dbConn = mysql_connect ($dbHost, $dbUser, $dbPass) or die ('MySQL connect failed. ' . mysql_error());
mysql_select_db($dbName) or die('Cannot select database. ' . mysql_error());
function &dbQuery($sql)
{
$result = mysql_query($sql) or die("Error: ".mysql_error());
return $result;
}
function dbAffectedRows()
{
global $dbConn;
return mysql_affected_rows($dbConn);
}
function &dbFetchArray($result, $resultType = MYSQL_NUM) {
return mysql_fetch_array($result, $resultType);
}
function &dbFetchAssoc($result)
{
return mysql_fetch_assoc($result);
}
function &dbFetchRow($result)
{
return mysql_fetch_row($result);
}
function dbFreeResult($result)
{
return mysql_free_result($result);
}
function dbNumRows($result)
{
return mysql_num_rows($result);
}
function dbSelect($dbName)
{
return mysql_select_db($dbName);
}
function dbInsertId()
{
return mysql_insert_id();
}
?>**********ORIGINAL POST*****************
So I've researched this to the best of my ability online. As far as I can tell, what has happened is that my webhost updated PHP to 4.4.2 and it created a number of variable reference errors on my site.
Here is my site: http://www.weddingwebsites.com
The errors I am getting are like this:
Notice: Only variables should be assigned by reference in /home/wedweb/public_html/library/review-functions.php on line 210
Notice: Only variable references should be returned by reference in /home/wedweb/public_html/library/database.php on line 26
Notice: Only variables should be assigned by reference in /home/wedweb/public_html/library/review-functions.php on line 219
Notice: Only variables should be assigned by reference in /home/wedweb/public_html/library/compairesite-functions.php on line 61
The errors seem to be in only about 5 or 6 php files.
I found this after doing a search on the error:
http://codex.gallery2.org/index.php/Gal ... s_wrong.3F
I wrote my localhost and he responded with this:
Here is some of the code that is being referenced by the error messages:Actually that is the exact resource I was looking at, we are running php 4.4.2 and using 2.6.2 of the zend optimizer. I tried to kick the optimization_level down to 14 but that didn't have any effect. And as for suppression warning that would be a problem since these warnings that are present are there in place of the actual content, disabling the warnings would probably just result in blank areas.
From what I understand the issue is that passing by reference like this is rather problematic since as soon as the function is completed all associated data is destroyed.
Code: Select all
$result =& dbQuery($sql);Code: Select all
return mysql_fetch_assoc($result);Code: Select all
$result1 =& dbquery($sql1);Code: Select all
$avgrating_result =& dbquery($select_avgrating);So, I guess I'd like to know if I could just edit these code lines myself or if it's going to take siginificant rewriting of the code?
Thanks in advance for the help![/quote]