NameSilo

Function fails with if

NamecheapNamecheap
SpaceshipSpaceship
SpaceshipSpaceship
Watch

adam_uk

Established Member
Impact
20
sup people

got a strange problem

ive got a function called getdata()

and well the code is below
PHP:
<?
function getdata($fname, $id){


echo"<tr>
	<td height='1' bgcolor='#c0c0c0' align="center">$fname </td>
	<td height='1' bgcolor='#33ccff' align="center"><input type='radio' name='pupil$id' value='In' ></td>
	<td height='1' bgcolor='#c0c0c0' align="center"><input type='radio' name='pupil$id' value='Absent' checked='checked'></td>
<td height='1' bgcolor='#33ccff' align="center"><input type='radio' name='pupil$onetwo' value='Doctors' $c3></td>
	<td height='1' bgcolor='#c0c0c0' align="center"><input type='radio' name='pupil$onetwo' value='Sickness' $c4></td>
	<td height='1' bgcolor='#33ccff' align="center"><input type='radio' name='pupil$onetwo' value='Holiday' $c5></td>
	<td height='1' bgcolor='#c0c0c0' align="center"><input type='radio' name='pupil$id' value='Late'></td>
	<td height='1' bgcolor='#33ccff' align="center"><input type='text' name='pupil$id$data' class='textbox'></td>
</tr>";

}

getdata($pupil11a, 1);
getdata($pupil22a, 2);
getdata($pupil33a, 3);
getdata($pupil44a, 4);
getdata($pupil55a, 5);
getdata($pupil66a, 6);
getdata($pupil77a, 7);
getdata($pupil88a, 8);
getdata($pupil99a, 9);
getdata($pupil000a, 10);
getdata($pupil111a, 11);
getdata($pupil222a, 12);
getdata($pupil333a, 13);
getdata($pupil444a, 14);
getdata($pupil555a, 15);
getdata($pupil666a, 16);
getdata($pupil777a, 17);
getdata($pupil888a, 18);
getdata($pupil999a, 19);
getdata($pupil0000a, 20);
getdata($pupil1111a, 21);
getdata($pupil2222a, 22);
getdata($pupil3333a, 23);
getdata($pupil4444a, 24);
getdata($pupil5555a, 25);
getdata($pupil6666a, 26);
getdata($pupil7777a, 27);
getdata($pupil8888a, 28);
getdata($pupil9999a, 29);
getdata($pupil00000a, 30);



?>


that works fine as it is (well not how i wants it but it executes it)

but if i change it to this


PHP:
<?
function getdata($fname, $id){

if($fname ==""){
echo" fudgickles";
}else{
echo"<tr>
	<td height='1' bgcolor='#c0c0c0' align="center">$fname </td>
	<td height='1' bgcolor='#33ccff' align="center"><input type='radio' name='pupil$id' value='In' ></td>
	<td height='1' bgcolor='#c0c0c0' align="center"><input type='radio' name='pupil$id' value='Absent' checked='checked'></td>
<td height='1' bgcolor='#33ccff' align="center"><input type='radio' name='pupil$onetwo' value='Doctors' $c3></td>
	<td height='1' bgcolor='#c0c0c0' align="center"><input type='radio' name='pupil$onetwo' value='Sickness' $c4></td>
	<td height='1' bgcolor='#33ccff' align="center"><input type='radio' name='pupil$onetwo' value='Holiday' $c5></td>
	<td height='1' bgcolor='#c0c0c0' align="center"><input type='radio' name='pupil$id' value='Late'></td>
	<td height='1' bgcolor='#33ccff' align="center"><input type='text' name='pupil$id$data' class='textbox'></td>
</tr>";
}
}

getdata($pupil11a, 1);
getdata($pupil22a, 2);
getdata($pupil33a, 3);
getdata($pupil44a, 4);
getdata($pupil55a, 5);
getdata($pupil66a, 6);
getdata($pupil77a, 7);
getdata($pupil88a, 8);
getdata($pupil99a, 9);
getdata($pupil000a, 10);
getdata($pupil111a, 11);
getdata($pupil222a, 12);
getdata($pupil333a, 13);
getdata($pupil444a, 14);
getdata($pupil555a, 15);
getdata($pupil666a, 16);
getdata($pupil777a, 17);
getdata($pupil888a, 18);
getdata($pupil999a, 19);
getdata($pupil0000a, 20);
getdata($pupil1111a, 21);
getdata($pupil2222a, 22);
getdata($pupil3333a, 23);
getdata($pupil4444a, 24);
getdata($pupil5555a, 25);
getdata($pupil6666a, 26);
getdata($pupil7777a, 27);
getdata($pupil8888a, 28);
getdata($pupil9999a, 29);
getdata($pupil00000a, 30);



?>
its like it skips it, it doesnt give me any errors no nothing just an empty page


anyone got any advice on this

thanks
adam
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
if($fname ==""){
echo" fudgickles";
}else{
echo"<tr>

have to have a space's in statments.

Im assuming thats your problem try.

PHP:
if ($fname == "") { 
echo "fudgickles"; 
} else { 
echo "<tr>

also just noticed you had echo" fudgickles"; the echo" would not make it an echo thats why it is not producing anything.
try using a color coded editor EG dreamweaver, it would pick up things like that highlihting blue or black if error.
 
0
•••
Originally posted by Pablo
have to have a space's in statments.

Im assuming thats your problem try.

PHP:
if ($fname == "") { 
echo "fudgickles"; 
} else { 
echo "<tr>

also just noticed you had echo" fudgickles"; the echo" would not make it an echo thats why it is not producing anything.
try using a color coded editor EG dreamweaver, it would pick up things like that highlihting blue or black if error.

ive never put spaces in my if statements and they work fine, also echo "asdasd"; does the same job as echo" asdasd";

works fine for me

i think ive solved the problem now, it was something to do with the server configuration

thanks
 
0
•••
I think you should probably start getting yourself out of them bad habits while you can, especially the echo" one. :D I think the with the spaces makes for much nicer and more readable code and I'm sure you'll find most everyone else does too. That's just what I think though. :beer:
 
0
•••
Originally posted by deadserious
I think you should probably start getting yourself out of them bad habits while you can, especially the echo" one. :D I think the with the spaces makes for much nicer and more readable code and I'm sure you'll find most everyone else does too. That's just what I think though. :beer:

yeh i now i should lol

but its easier said than done
 
0
•••
DomainEasy: white label portfolios are live. Enable yours.

We're social

Escrow.com
Spaceship
Escrowly
CryptoExchange.com
Domain Recover
URLs.com
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back