954,580 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

problem in php inside html

this is my html code in which i want to get info from the server and insert it into the list items and show it in the browser, using loop .so i am using php but this code is not working for me . please somebody help me !!!!!!!!!

<body>

<div class="infiniteCarousel">
<div class="wrapper" style="overflow: hidden;">
<ul>
<?php
// Connects to your Database 
 mysql_connect("localhost", "root", "") or die(mysql_error()) ; 
 mysql_select_db("a") or die(mysql_error()) ; 
 
 //Retrieves data from MySQL 
 $data = mysql_query("SELECT * FROM employees") or die(mysql_error()); 
 //Puts it into an array 
 while($info = mysql_fetch_array( $data )) 
 { 
?>
<li > 
<?php 
 Echo "<img width="240" height="240" alt="Wonky Buildings"  src=images/".$info

['photo'] ."> ";  // this part is not working 
?>

</li>
<?php   } ?>

</ul>
</div>
<a class="arrow back">&lt;</a>
<a class="arrow forward">&gt;</a>
</div>


</body>


i am getting this syntax error

Parse error: syntax error, unexpected T_LNUMBER, expecting ',' or ';'

aaloo
Junior Poster in Training
76 posts since Oct 2011
Reputation Points: 22
Solved Threads: 0
 

The problem is related to the double quotes, rewrite that line 19:

$img = $info['photo'];
echo '<img width="240" height="240" alt="Wonky Buildings"  src="images/'. $img .'>';

Or:

echo "<img width=\"240\" height=\"240\" alt=\"Wonky Buildings\" src=\"images/".$img ."\">";

Or:

echo "<img width='240' height='240' alt='Wonky Buildings' src='images/$img'>";

bye

cereal
Master Poster
709 posts since Aug 2007
Reputation Points: 214
Solved Threads: 120
 

thanks :)

aaloo
Junior Poster in Training
76 posts since Oct 2011
Reputation Points: 22
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: