I am using php include to include this function and it is giving me a: Parse error: syntax error, unexpected T_FUNCTION in /home1/stomperg/public_html/nintendogamesonline/functions.php on line 3 error. Here is the code of the functions.php file: <? php function showHannsgMonitor($monitor) { echo( <div class="section"> <div class="images"> <img class="logo" src="images/logos/hannsg.png" alt="Hanns-G" /> <img class="monitor" src="images/hannsg/$monitor.jpg" alt="Hanns-G $monitor" /> </div> <div class="description"> <a href="#"></a> <ul> <li><strong>Color:</strong> <?php $hannsg['$monitor'][0] ?></li> <li><strong>Size:</strong> <?php $hannsg['$monitor'][1] ?></li> <li><strong>Resolution:</strong> <?php echo $hannsg['$monitor'][2] ?></li> <li><strong>Response Time:</strong> <?php echo $hannsg['$monitor'][3] ?></li> <li><strong>Input:</strong> <?php echo $hannsg['$monitor'][4] ?></li> <li><strong>Brightness:</strong> <?php echo $hannsg['$monitor'][5] ?></li> <li><strong>Contrast Ratio:</strong> <?php echo $hannsg['$monitor'][6] ?></li> <li><strong>Viewing Angle:</strong> <?php echo $hannsg['$monitor'][7] ?></li> <li><strong>Pixel Pitch:</strong> <?php echo $hannsg['$monitor'][8] ?></li> </ul> </div> <div class="revieworbuy"> </div> <div class="clear"></div> </div>); } ?> Thanks for anyones help!!
I don't believe echo has parentheses... () You should use quotes. That may make it think it's an unknown function.
can I have echos in echos? I have a multidimensional array and I am calling the array parts which is why I have those "<? php echo $hannsg['$monitor'][8] ?>" blocks in there. Is that my problem?
I am including a functions.php file in my index.html with one function that uses a multidimensional array data that is included as well, but I am getting an error that halts the loading of the page. Here is the error: Parse error: syntax error, unexpected T_FUNCTION in /home1/stomperg/public_html/nintendogamesonline/functions.php on line 3 And here is the code to create the function that I am including: <? php function showMonitor($monitor) { echo( <div class="section"> <div class="images"> <img class="logo" src="images/logos/hannsg.png" alt="Hanns-G" /> <img class="monitor" src="images/hannsg/$monitor.jpg" alt="Hanns-G $monitor" /> </div> <div class="description"> <a href="#"></a> <ul> <li><strong>Color:</strong> $hannsg['$monitor'][0]</li> <li><strong>Size:</strong> $hannsg['$monitor'][1]</li> <li><strong>Resolution:</strong> $hannsg['$monitor'][2]</li> <li><strong>Response Time:</strong> $hannsg['$monitor'][3]</li> <li><strong>Input:</strong> $hannsg['$monitor'][4]</li> <li><strong>Brightness:</strong> $hannsg['$monitor'][5]</li> <li><strong>Contrast Ratio:</strong> $hannsg['$monitor'][6]</li> <li><strong>Viewing Angle:</strong> $hannsg['$monitor'][7]</li> <li><strong>Pixel Pitch:</strong> $hannsg['$monitor'][8]</li> </ul> </div> <div class="revieworbuy"> </div> <div class="clear"></div> </div>); } ?> ^^^ Here is what the original post should have said if that helps any. Thanks!
function showHannsgMonitor($monitor) { echo '<div class="section"> <div class="images"> <img class="logo" src="images/logos/hannsg.png" alt="Hanns-G" /> <img class="monitor" src="images/hannsg/$monitor.jpg" alt="Hanns-G $monitor" /> </div> <div class="description"> <a href="#"></a> <ul> <li><strong>Color:</strong>'.$hannsg['$monitor'][0].'</li> <li><strong>Size:</strong>'.$hannsg['$monitor'][1].'</li> <li><strong>Resolution:</strong>'.$hannsg['$monitor'][2].'</li> <li><strong>Response Time:</strong>'.$hannsg['$monitor'][3].'</li> <li><strong>Input:</strong> '.$hannsg['$monitor'][4].'</li> <li><strong>Brightness:</strong>'.$hannsg['$monitor'][5].'</li> <li><strong>Contrast Ratio:</strong>'.$hannsg['$monitor'][6].'</li> <li><strong>Viewing Angle:</strong> '. $hannsg['$monitor'][7].'</li> <li><strong>Pixel Pitch:</strong>'.$hannsg['$monitor'][8].'</li> </ul> </div> <div class="revieworbuy"> </div> <div class="clear"></div> </div>'; } PHP:
that works, but my inserted parameter is not replacing the variable. EXAMPLE: when I call <?php showHannsgMonitor("JW155DBB") ?> it doesnt replace $monitor with JW155DBB everywhere I told it to. ------------------------ what i what to happen is when the function is called, i want the parameter to replace all the variables in the code and then i want the function to print the raw code onto the html document exactly where it is called. maybe this helps some more?
function showHannsgMonitor($monitor) { global $hannsg; //<--you have to set your global variable inside your function echo '<div class="section"> <div class="images"> <img class="logo" src="images/logos/hannsg.png" alt="Hanns-G" /> <img class="monitor" src="images/hannsg/$monitor.jpg" alt="Hanns-G $monitor" /> </div> <div class="description"> <a href="#"></a> <ul> <li><strong>Color:</strong>'.$hannsg[$monitor][0].'</li> <li><strong>Size:</strong>'.$hannsg[$monitor][1].'</li> <li><strong>Resolution:</strong>'.$hannsg[$monitor][2].'</li> <li><strong>Response Time:</strong>'.$hannsg[$monitor][3] .'</li> <li><strong>Input:</strong> '.$hannsg[$monitor][4].'</li> <li><strong>Brightness:</strong>'.$hannsg[$monitor][5].'</li> <li><strong>Contrast Ratio:</strong>'.$hannsg[$monitor][6] .'</li> <li><strong>Viewing Angle:</strong> '. $hannsg[$monitor][7] .'</li> <li><strong>Pixel Pitch:</strong>'.$hannsg[$monitor][8] .'</li> </ul> </div> <div class="revieworbuy"> </div> <div class="clear"></div> </div>'; } PHP:
but if i want to replace all the '$monitor' variables and NONE of the '$hannsg' ones then do i change the global to $monitor or leave it as is? php_lover, you are a great help rep+