Page 1 of 1

i need help in php

Posted: Tue Mar 25, 2003 2:17 am
by forgun
this ids a part from a function

Code: Select all

$lk = mysql_connect($serv,$user,$pass) or die ('Unable to do connection to the data base');
    mysql_select_db($dbnameї0] ,$lk);
    $qur = 'SELECT * from News  ORDER BY id DESC LIMIT 0, 6';
    $res = mysql_query($qur) or die ("error on the db" . $err = mysql_error());
    while ($row = mysql_fetch_array($res)) {
$day = $rowї'day'];
        switch ($rowї'byhow']) {
            case 'chef':
            $imgї0] = 'images/chef.jpg';
            $imgnum = 1;
            break;
            case 'forgun':
            $imgї0] = 'images/forgun.jpg';
            $imgnum = 1;
            case 'c&f':
            $imgї0] = 'images/chef.jpg';
            $imgї1] = 'images/forgun.jpg';
            $imgnum = 2;
            break;
            default:
            $imgї0] = 'images/forgun.jpg';
            $imgnum = 1;
        }
        $up = array( array (
        'title' => $rowї'title'] ,
        'day' => $day ,
        'date' => $rowї'date'] ,
        'time' => $rowї'time'] ,
        'body' => $rowї'body'] ,
        'by' => $rowї'byhow'] ,
        'imgnum' => $imgnum ,
        'imgpath1' => $imgї0] ,
        'imgpath2' => $imgї1] 
        ) );
        print_r($up);
        return $up;
    }
all is work all but the the return command why its not working
all the data is work and the array is been work in the function all but the command return $up;
why?

Posted: Tue Mar 25, 2003 4:42 am
by volka
so print_r($up); within the function does show some data but

Code: Select all

...
$arr = the_function(...);
echo 'returned: <pre>';
print_r($arr);
echo '.</pre>';
does not?

Posted: Tue Mar 25, 2003 7:30 am
by forgun
this what is give me the print_r

Code: Select all

Array ( &#1111;0] => Array ( &#1111;title] => &#1504;&#1489;&#1492;&#1497;&#1495; &#1111;day] => N/A &#1111;date] => 2003-03- &#1111;time] => 09:17 &#1111;body] => &#1506;&#1490;&#1499;&#1495;&#1497;&#1495;&#1506;&#1490;&#1491; &#1111;by] => chef &#1111;imgnum] => 1 &#1111;imgpath1] => images/chef.jpg &#1111;imgpath2] => ) )
when i put at in side the function
in the out side isn't give any nothing

Posted: Tue Mar 25, 2003 1:10 pm
by RedDragon
well im not sure why your code doesnt work.... try using

Code: Select all

return array(0 => $a,
	   1 => $b,
	   2 => $c,
	   3 => $d);