Re: (PHP) Help - What is wrong with this code - Please help

From: Date: Fri, 28 Jul 2000 09:47:10 +0000
Subject: Re: (PHP) Help - What is wrong with this code - Please help
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-8751@lists.php.net to get a copy of this message
David Tandberg-Johansen wrote: > > Hello All! > > I have tried for over a week now , reading from the manual (www.php.net) an > been to php.faqts.com and I still don't know what i do wrong. > > Could anyone give me a hint?? > *** Use return in your functions (see below). Also use global when calling "external" (global) variables from inside your functions. > David > > mk_hdl.php > ********************************************* > <?PHP > $hostname = "localhost"; > $username = "root"; > $password = ""; > $dbName = "database"; > > $name_first ="Name"; > $name_sir ="Second_name"; > > function get_character ($name_first ,$name_sir) > { > $rest1 = substr ($name_first , 0, 1); > $rest2 = substr ($name_sir, 0, 1); > $rest3 = "$rest1$rest2"; > $rest3; *** return $rest3; > } > > MYSQL_CONNECT($hostname, $username, $password) OR DIE("Unable to connect to > database"); > @mysql_select_db( "$dbName") or die( "Unable to select database"); > > function get_number () > { > $result = mysql_db_query($dbName, "select count(*) as kundeid from > kunder"); > $num = mysql_result($result,0,"kundeid"); > $num; *** return $num; > } > > function mk_hdl () > { *** global $fornavn,$etternavn; > get_character($fornavn,$etternavn); > get_number(); > $hdl = "$rest3$num"; > $hdl; *** return $hdl; > } > > echo hdl(); > ?> > ******************************** > hellekin

« previous php.general (#8751) next »