[Wylug-help] FC4->FC5 upgrade PHP issues.

Roger roger.bea at blueyonder.co.uk
Thu Feb 8 17:37:49 GMT 2007


I think...

The problem is indeed in the array_shift call - which, the error message 
implies to me, wants a variable, not the output from another function 
call.  If I'm right, then:

  $r_det_step1=loadhash3(
    "select r_id as key, * from requests where r_id = $dets[o_r_id]",0);
  $r_det = array_shift($r_det_step1);

should work perfectly.  My interpretation is that the 'call by 
reference' (which means the function works on the original data, rather 
than on a copy) prefers to have a formally assigned bit of memory (a 
variable) to work on, rather than some that is temporarily assigned to 
return the result from loadhash3() (by a process that isn't formally 
defined, so may not work in future implementations).

NB that interpretation is based on academic knowledge, not practical 
experience, so...  ;^)

Roger

Gary Stainburn wrote:
> Secondly, I'm getting lots of :-
> 
> PHP Strict Standards:  Only variables should be passed by reference in ... on 
> line ...
> 
> One such line is :-
> 
> $r_dets=array_shift(loadhash3("select r_id as key, * from requests where r_id 
> = $dets[o_r_id]",0));
> 
> where loadhash3 returns a hash of records with the format 'key' -> hash of 
> fields. In this instance it only returns 1 row from the database, and the 
> hash of fields I want into $r_dets ($r_dets['r_id'], $r_dets['r_regno'], 
> etc).
> 
> Without the array_shift I don't get the error message, but have to refer to 
> fields as $r_dets[$dets['o_id']]['r_regno'] which obviously isn't as nice.
> 
> Can anyone tell me why this is not the right way to do things, and how I 
> should change the code to improve it.





More information about the Wylug-help mailing list