Page 1 of 1

Changing string to array

Posted: Sun Sep 05, 2004 2:15 am
by thewormman
Hi
Could someone tell me in laymans language how I can turn this string

Code: Select all

<?php
 $catid = array_shift(mysql_fetch_row(mysql_query("select id from lma_categories where parent = '$ipar' and name = '".str_replace("_", " ", $lastcat)."'")));   
?>
Into an array?
As when I execute the script it is in I get the following error message
Warning: array_shift() [function.array-shift]: The argument should be an array in /home3/davemcc/public_html/1coolwebsite.co.uk/lma/directory on line 774
Many thanks
Dave

Posted: Sun Sep 05, 2004 10:32 am
by feyd
break the line apart into individual function calls. Although it can be fun to compact code into the smallest space, it is counter productive when still learning and developing. You likely have an error in the sql or maybe the query found zero records.