Jump to content


Photo

Bad syntax in database retrieval


  • Please log in to reply
2 replies to this topic

#1 Timmyhavoc

Timmyhavoc
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 25 April 2006 - 03:58 PM

Hi
I recently upgraded our site to PHP version 3.4 and now alot of my scripts arent working and i get this notorious and dredded error message:

Notice: Only variable references should be returned by reference in /homepages/20/d158757983/htdocs/ebshop/library/database.php on line 9

Notice: Only variable references should be returned by reference in /homepages/20/d158757983/htdocs/ebshop/library/database.php on line 25

I know this is to do with changing versions but im not the most PHP skilled person so can't see where the errors are, can someone shed some light?

The code producing the error reads like this:

1 - <?php
2 - require_once 'config.php';
3 - 
4 - $dbConn = mysql_connect ($dbHost, $dbUser, $dbPass) or die ('MySQL connect failed. ' . mysql_error());
5 - mysql_select_db($dbName) or die('Cannot select database. ' . mysql_error());
6 - 
7 - function &dbQuery($sql)
8 - {
9 -    return mysql_query($sql);
10 - }
...
23 - function &dbFetchAssoc($result)
24 - {
25 -     return mysql_fetch_assoc($result);
26 - }

Id appreciate any help!

#2 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 25 April 2006 - 04:50 PM

Why are you using such an ancient version of php? Where up to 5.0.2 now, or at least a stable version of 4.

Anyway, try removing the &'s from the start of your function definitions.

#3 Timmyhavoc

Timmyhavoc
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 26 April 2006 - 01:42 PM

Amazing! that certainly got rid of those warnings. thanks! what seems obvious to you can slip past my eyes so easily.

As for versions Its pretty hard for me to keep up, php is only one of the things i do at work. I generally have to source old scripts ive used in the past to save time.

One other thing which is probably also related to PHP versions, my .htaccess isnt working anymore and its needed to redirect all the include files. It looks like this:

php_value include_path ".;\"my_server_directory"\htdocs\ebshop\;\"my_server_directory"\htdocs\ebshop\library\; \"my_server_directory"\htdocs\ebshop\include\"

Am i using old code again or am i getting the syntax wrong?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users