James Murrell
asked on
PHP show image based on value in mysql Database and the image folder #raspberrypi
Hi hope you can help last year this worked this year it is not: upgrade php i think
my php code is
the html view score is
what i need is
no spaces in the end part hope you guys can help. this is for a free fantasy F1 league i do with friends
I forgot to mention the images ref is stored in database like "3 Nico ROSBERG"
my php code is
<img class=polaroid height=70 src=../images/drivers/".SUBSTR($_SESSION['Driver1'],0,4).".jpg/>
the html view score is
<img class=polaroid height=70 src=../images/drivers/ 3 .jpg/>
what i need is
<img class=polaroid height=70 src=../images/drivers/3.jpg/>
no spaces in the end part hope you guys can help. this is for a free fantasy F1 league i do with friends
I forgot to mention the images ref is stored in database like "3 Nico ROSBERG"
ASKER
apologies i pasted a bit of code:
whole code does have "" around
here is full code
] ,4). " </b>and <b>" . SUBSTR($_SESSION['Driver2' ],4) . " ,</b><p> <img class=polaroid height=70 src=../images/drivers/".SU BSTR($_SES SION['Driv er1'],0,4) .".jpg/><i mg class=polaroid height=80 src=/images/drivers/".SUBS TR($_SESSI ON['Driver 2'], 0,4).".jpg caption ".$_SESSION['Driver2'] ." <br /> <p>".
whole code does have "" around
here is full code
echo "<h3><span>Your Team Name is :<b> " . $_SESSION['TeamName']. "</span> </h3> " . "</b> Your choice of drivers are <b> " . substr($_SESSION['Driver1'] ,4). " </b>and <b>" . SUBSTR($_SESSION['Driver2'],4) . " ,</b><p> <img class=polaroid height=70 src=../images/drivers/".SUBSTR($_SESSION['Driver1'],0,4).".jpg/><img class=polaroid height=80 src=/images/drivers/".SUBSTR($_SESSION['Driver2'], 0,4).".jpg caption ".$_SESSION['Driver2'] ." <br /> <p>".
echo "<h3><span>Your Team Name is :<b> " . $_SESSION['TeamName']. "</span> </h3> " . "</b> Your choice of drivers are <b> " . substr($_SESSION['Driver1'
If $_SESSION['Driver1'] is "3 Nico ROSBERG" you have to use
substr(trim($_SESSION['Driver1']), 0, 1)
This code snippet appears to have a PHP parse error in it.
Please do this for us: Print out the contents of $_SESSION. Use var_dump() to print it. Post that information here. Once we see the data we can give you the exact code you need to create the HTML document.
If you're new to PHP and want to find some good learning resources, this article can help:
https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html
Please do this for us: Print out the contents of $_SESSION. Use var_dump() to print it. Post that information here. Once we see the data we can give you the exact code you need to create the HTML document.
If you're new to PHP and want to find some good learning resources, this article can help:
https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html
ASKER
Thanks Ray: ok my error again here is full code
plus here is var_dump()
Thanks and apologies for not post full code originally
echo "<h3><span>Your Team Name is :<b> " . $_SESSION['TeamName']. "</span> </h3> " . "</b> Your choice of drivers are <b> " . substr($_SESSION['Driver1'] ,4). " </b>and <b>" . SUBSTR($_SESSION['Driver2'],4) . " ,</b><p> <img class=polaroid height=70 src=../images/drivers/".SUBSTR($_SESSION['Driver1'],0,4).".jpg/><img class=polaroid height=80 src=/images/drivers/".SUBSTR($_SESSION['Driver2'], 0,4).".jpg caption ".$_SESSION['Driver2'] ." <br /> <p>".
"<p>".
"Your choice of teams are <b>" . SUBSTR($_SESSION['Team1'],4) . " </b> and <b>" . SUBSTR($_SESSION['Team2'],4) . " </b><p> <img class=polaroid height=80 src=/images/teams/".SUBSTR($_SESSION['Team1'], 0,4).".jpg /> <img class=polaroid height=80 src=../images/teams/".SUBSTR($_SESSION['Team2'], 0,4).
".jpg /><br /><p>Team win most Poles is:<b> " . SUBSTR($_SESSION['Total'],4)."</b> and your double point race is: <b> Race " . $_SESSION['MyProducts']." </b><p> <img class=polaroid height=80 src=../images/teams/".SUBSTR($_SESSION['Total'], 0,4).".jpg /> <img class=polaroid height=80 src=../images/circuits/".$_SESSION['MyProducts'].".jpg /><br/><p>" .
"<P>Your choice of Postion for Lewis is : <b> " . $_SESSION['LewisEndofyearPosition'] . "</b><br /><p>";
plus here is var_dump()
array(12) { ["TeamName"]=> string(8) "cs97jjm3" ["Email"]=> string(12) "ja@shdjs.com" ["FullName"]=> string(9) "jkasjkdjk" ["Driver1"]=> string(21) " 1 Lewis HAMILTON " ["Driver2"]=> string(18) " 3 Nico ROSBERG " ["Team1"]=> string(14) " 131 Mercedes " ["LewisEndofyearPosition"]=> string(1) "1" ["Team2"]=> string(15) " 9 Red Bull " ["Total"]=> string(12) "131 Mercedes" ["Password"]=> string(32) "b1a273f615207e00970cfb5d1e9a800d" ["MyProducts"]=> string(2) "14" ["submissionID"]=> string(1) "7" }
Thanks and apologies for not post full code originally
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks with explanation i understood problem:
You're welcome!
PHP functions are not case sensitive. PHP variables, object property names, and array indexes are case-sensitive.
@Ray: thank you. I was sure everything was case-sensitive! Or better, I never dedicated a thought to that: I just always wrote in lowercase... And when I saw that SUBSTR and your comment about parse errors I thought you were talking about that, without noticing the missing param for 2 substr calls.
Well, another piece of knowledge in my pocket :-)
Cheers
Well, another piece of knowledge in my pocket :-)
Cheers
Open in new window