Page 1 of 1

Looping problems

Posted: Wed Jan 03, 2007 6:30 am
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]

Posted: Wed Jan 03, 2007 6:39 am
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

Posted: Wed Jan 03, 2007 6:42 am
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>");

Posted: Wed Jan 03, 2007 7:53 pm
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

Posted: Thu Jan 04, 2007 1:15 am
by mickd
If your server is running linux, it would be because it's case sensitive.

Posted: Thu Jan 04, 2007 9:21 am
by wildwobby
I think your problem is that your for statement is suppose to be seperated by , (comma) not ; (semi-colons).

Posted: Thu Jan 04, 2007 9:33 am
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
}

Posted: Thu Jan 04, 2007 10:07 am
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