Looping problems

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
bebensiganteng
Forum Newbie
Posts: 23
Joined: Wed Jan 03, 2007 6:03 am
Location: UAE

Looping problems

Post by bebensiganteng »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hi guys,

Please Help me..  

I've tried this simple code

Code: Select all

print("<ul>");
for ($i = 0;$i<$num;$i++) {
	print ("<li><a href='index.php?init=porto&prod=".$prod."&num=".$num."&list=".$i."'><img src='images/".$prod."/thumb/".$prod.$i.".jpg' border='0' alt='thumb'  /></a></li>");
	print("<p>this ".$i."</p>");
	}
print("</ul>");
This supposed to create a list of images, when I tried it on the localhost it works! but when i upload it to the server, the pictures did not appeared

to see the problem pls follow this link

http://www.rahmat79.com/Labo/index.php? ... 35&list=12

thanks
rhmt


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
reecec
Forum Contributor
Posts: 218
Joined: Sun Apr 02, 2006 7:12 am

Post by reecec »

hi

when i viewed one of your images on its own it has the directory of
this image couldnt be found on the server are you sure the images are there


thanks reece
reecec
Forum Contributor
Posts: 218
Joined: Sun Apr 02, 2006 7:12 am

Post by reecec »

heres your problem

i think the .jpg should be .JPG



your new code:

Code: Select all

print("<ul>");
for ($i = 0;$i<$num;$i++) {
print ("<li><a href='index.php?init=porto&prod=".$prod."&num=".$num."&list=".$i."'><img src='images/".$prod."/thumb/".$prod.$i.".JPG' border='0' alt='thumb' /></a></li>");
print("<p>this ".$i."</p>");
}
print("</ul>");
bebensiganteng
Forum Newbie
Posts: 23
Joined: Wed Jan 03, 2007 6:03 am
Location: UAE

Post by bebensiganteng »

Hi reecec,

Yes changing the text case worked! thanks a lot...... :D

but if its not too much trouble, could you explain why changing the case could worked?

I'm still dont understand why does the code worked on the localhost but didnt worked on the server
Sorry, i'm still new at php

Thanks
mickd
Forum Contributor
Posts: 397
Joined: Tue Jun 21, 2005 9:05 am
Location: Australia

Post by mickd »

If your server is running linux, it would be because it's case sensitive.
wildwobby
Forum Commoner
Posts: 66
Joined: Sat Jul 01, 2006 8:35 pm

Post by wildwobby »

I think your problem is that your for statement is suppose to be seperated by , (comma) not ; (semi-colons).
mickd
Forum Contributor
Posts: 397
Joined: Tue Jun 21, 2005 9:05 am
Location: Australia

Post by mickd »

Nope, for loops do use semi-colons not commas

Code: Select all

for ( initialize a counter; conditional statement; increment a counter){
	// do this
}
reecec
Forum Contributor
Posts: 218
Joined: Sun Apr 02, 2006 7:12 am

Post by reecec »

thats ok happy to help!

mickd wrote:If your server is running linux, it would be because it's case sensitive.
yes this is different when running windows its not case sensitive



EDIT: So your PHP Code is fine

thanks reece
Post Reply