PHP Help

v2^

v2^

Associate
Joined
21 Oct 2002
Posts
1,075
Hello all

The Property of $killers is Saloman in my database and this is the code i am using.

---


<?
$tech = "$killers";

if ($tech == "Saloman") {
?>
<img src="../killdb/killer-images/<? print mysql_result($result,0,"killers"); ?>.jpg" alt="<? print mysql_result($result,0,"killers"); ?>, Eve Online" width="80" height="80" style="border-style: solid; border-width: 1px; border-color: #ffffff;">
<?
}

else {
?>
<img src="../killdb/killer-images/Unknown.jpg" alt="<? print mysql_result($result,0,"killers"); ?>, Eve Online" width="80" height="80" style="border-style: solid; border-width: 1px; border-color: #ffffff;">
<?
}
?>

--

So if Tech = Saloman if will show his image if not it will shown another image but it will not work. What am i doing wrong :(

All help apreciated as im banging my head on the desk.

Thanks in advace.
 
Seft said:
what is the error?

EDIT could be first line, remove speech marks.

It shows the unknown image when it should show the Saloman Image.

I tried without the speech marks and its still the same :(
 
Seft said:
what url is it giving for the unknown image.

It would be a good idea to have some echos in the if loops to see if it's correctly choosing the first one.

Oh and print $tech too.

Ok i changed the print in the image url to $tech if thats what you meant, this is the page in question http://guc.webinventions.co.uk/killdb/killinfotest.php?id=2786

---

<?
$tech = $killers;

if ($tech == "Saloman") {
?>
<img src="../killdb/killer-images/<? print mysql_result($tech,0,"killers"); ?>.jpg" alt="<? print mysql_result($result,0,"killers"); ?>, Eve Online" width="80" height="80" style="border-style: solid; border-width: 1px; border-color: #ffffff;">
<?
}

else {
?>
<img src="../killdb/killer-images/Unknown.jpg" alt="<? print mysql_result($result,0,"killers"); ?>, Eve Online" width="80" height="80" style="border-style: solid; border-width: 1px; border-color: #ffffff;">
<?
}
?>
 
Last edited:
Beansprout said:
What's $killers?

There's also no point doing $tech = $killers, you're just creating another variable which adds to the confusion :)

Killers is a field in my database that stores the a persons name from a killmail in eve online. This one im testing has the property Saloman.
 
Gman said:
long shot but you could try doing a trim on $tech as some whitespaces might be playing with the if statement

Any chance you could helkp me on that ;)

$tech = trim(substr((chr(13) ,""));

??
 
no joy :(

<?
$tech = "$killers";
$tech = trim($killers);

if ($tech == "Saloman") {
?>
<img src="../killdb/killer-images/<? print mysql_result($tech,0,"killers"); ?>.jpg" alt="<? print mysql_result($result,0,"killers"); ?>, Eve Online" width="80" height="80" style="border-style: solid; border-width: 1px; border-color: #ffffff;">
<?
}

else {
?>
<img src="../killdb/killer-images/Unknown.jpg" alt="<? print mysql_result($result,0,"killers"); ?>, Eve Online" width="80" height="80" style="border-style: solid; border-width: 1px; border-color: #ffffff;">
<?
}
?>
 
Gman said:
looks to me like its saloman with a lower case 's' and your compairing it against Saloman with an uppercase 'S'

try changing your database entry to a uppercase 'S' or change your if statement Saloman to a lowercase 's'

Awesome it works a treat :)

Thanks so much for the help.
 
Back
Top Bottom