i need help in php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
forgun
Forum Commoner
Posts: 61
Joined: Wed Jan 29, 2003 6:05 am
Contact:

i need help in php

Post 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?
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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?
User avatar
forgun
Forum Commoner
Posts: 61
Joined: Wed Jan 29, 2003 6:05 am
Contact:

Post 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
RedDragon
Forum Newbie
Posts: 7
Joined: Wed Feb 19, 2003 3:16 pm
Contact:

Post 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);
Post Reply