simple php code (arrays)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
rocky_man
Forum Newbie
Posts: 1
Joined: Fri Jan 09, 2004 6:16 am

simple php code (arrays)

Post by rocky_man »

Hello, i am trying to learn some php and i am trying an example i saw somewhere but it does not seem to work can someone tell me please what i am doing wrong.

code below :

Code: Select all

<?
$pictures = array("tire.jpg", "oil.jpg", "spark_plug.jpg", "door.jpg",
                  "steering_wheel.jpg", "thermostat.jpg", "wiper_blade.jpg",
                  "gasket.jpg", "brake_pad.jpg");
shuffle($pictures);
?>
<html>
<head>
 <title>Bob's Auto Parts</title>
</head>
<body>
 <center>
 <h1>Bob's Auto Parts</h1>
 <table width = 100%>
   <tr>
<?
for ($i = 0; $i < 3; $i++)
{
 echo "<td align = center><img src="";
 echo $pictures[$i];
 echo "" width = 100 height = 100></td>;
}
?>
   </tr>
  </table>
 </center>
</body>
</html>
when i try to load this in my browser i get a parse error :
Parse error: parse error in /var/www/localhost/htdocs/frontpage.php on line 28

[Edit: Added PHP tags, and voila... --JAM]
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

This line

Code: Select all

echo "" width = 100 height = 100></td>;
Should be

Code: Select all

echo "" width = 100 height = 100></td>";
Your missed the closing quote ;)

Mark
User avatar
AVATAr
Forum Regular
Posts: 524
Joined: Tue Jul 16, 2002 4:19 pm
Location: Uruguay -- Montevideo
Contact:

Post by AVATAr »

rocky_man as you see in Bech100's text

Is very important to use colored code.
Post Reply