Hi,I am a beginner in php. And I am trying to create this php program where a user selects a picture and it displays it! Theare is an input page which is html and an processing page which is php! I seemes to have a problem in the processing page of the program.The problem is on line 22 in the processing page and it relates to escape character. How do I fix my issue please help I alredy spend more the several hours on it and still can't figure it out!
Here are the code for the processing page:
The major problem is on line 5 where it says:
Print "<img src=\ "Photos/$Random\"alt="Smiley face"height="50%" width="50%" border="5" <br/>";
There are issue with escape character and i can't fix it!
<?php
if(isset($_POST['Random']))
{
$Random = rand(0,12)." .jpg";
Print "<img src=\ "Photos/$Random\"
alt="Smiley face"height="50%" width="50%" border="5" <br/>";
}
else
{
if (isset($_POST['Anime']))
{
$Arr=$_POST['Anime'];
displayPhotos($Arr);
}
else
{
echo "You need to select photo.<br />";
}
function displayPhotos($Arr)
{
foreach ($Arr as $element)
{
print " <br/>";
Switch ($element){
Case 1:
echo "<img src="Photos/1.jpg" alt="Smiley face"
height="50%" width="50%" border="5" <br/>";
break;
Case 2:
echo "<img src="Photos/2.jpg" alt="Smiley face"
height="50%" width="50%" border="5" <br/>";
break;
Case 3:
echo "<img src="Photos/3.jpg" alt="Smiley face"
height="50%" width="50%" border="5" <br/>";
break;
Case 4:
echo "<img src="Photos/4.jpg" alt="Smiley face"
height="50%" width="50%" border="5" <br/>";
break;
Case 5:
echo "<img src="Photos/5.jpg" alt="Smiley face"
height="50%" width="50%" border="5" <br/>";
break;
Case 6:
echo "<img src="Photos/6.jpg" alt="Smiley face"
height="50%" width="50%" border="5" <br/>";
break;
Case 7:
echo "<img src="Photos/7.jpg" alt="Smiley face"
height="50%" width="50%" border="5" <br/>";
break;
Case 8:
echo "<img src="Photos/8.jpg" alt="Smiley face"
height="50%" width="50%" border="5" <br/>";
break;
Case 9:
echo "<img src="Photos/9.jpg" alt="Smiley face"
height="50%" width="50%" border="5" <br/>";
break;
Case 10:
echo "<img src="Photos/10.jpg" alt="Smiley face"
height="50%" width="50%" border="5" <br/>";
break;
Case 11:
echo "<img src="Photos/11.jpg" alt="Smiley face"
height="50%" width="50%" border="5" <br/>";
break;
Case 12:
echo "<img src="Photos/12.jpg" alt="Smiley face"
height="50%" width="50%" border="5" <br/>";
break;
}
}
}
}
?><
- Can someone also look at the rest of the code and tell me whats wrong and fix it for me Thank You!
Here is the input page incase anyone needs to lok at to solve the processing page codes:
<i>Please click any checkboxes to select a photo!</i>
<script type="text/javascript" language="javascript">// <![CDATA[
function checkAll(formName, checktoggle)
{
var checkboxes = new Array();
checkboxes = document[formName].getElementsByTagName('input');
for (var i=0; i<checkboxes.length; i++) {
if (checkboxes[i].type == 'checkbox') {
checkboxes[i].checked = checktoggle;
}
}
}
// ]]></script>
<fieldset>
<a onclick="javascript:checkAll('getIt', true);"
href="javascript:void();">check all</a>
<a onclick="javascript:checkAll('getIt', false);"
href="javascript:void();">uncheck all</a><br/>
<form action="Process_Page of the Project.php" method="post" name="getIt">
<input type="checkbox" name="Anime[]" value="1" />Code Geass Lelouch Of The Rebellion<br/>
<input type="checkbox" name="Anime[]" value="2" />Death Note<br/>
<input type="checkbox" name="Anime[]" value="3" />A Certain Magical Index<br/>
<input type="checkbox" name="Anime[]" value="4" />Kaze No Stigma<br/>
<input type="checkbox" name="Anime[]" value="5" />One Piece<br/>
<input type="checkbox" name="Anime[]" value="6" />Trigun<br/>
<input type="checkbox" name="Anime[]" value="7" />Tengen Toppa Gurren Lagann<br/>
<input type="checkbox" name="Anime[]" value="8" />Prince Of Tennis<br/>
<input type="checkbox" name="Anime[]" value="9" />Fairy Tail<br/>
<input type="checkbox" name="Anime[]" value="10" />Katekyo Hitman Reborn<br/>
<input type="checkbox" name="Anime[]" value="11" />Bleach<br/>
<input type="checkbox" name="Anime[]" value="12" />Silver Spoon(Gin no Saji)<br/><br/>
<input type="submit" name="formSubmit" value="Submit Choices" />
</form>
</fieldset>
<br/>
<fieldset>
<form action="Process_Page of the Project.php" method="post">
You can also click the Random button to view a random photo.<br/><br/>
<button name="Random" type="submit" value="R"> Randomize Me!</button>
</form>
</fieldset>
</p>
</body>
</html>
Please debug and tell me how you did it with comments! Thank You!