Arithmetic / variables problemo

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
Bennettman
Forum Contributor
Posts: 130
Joined: Sat Jun 15, 2002 3:58 pm

Arithmetic / variables problemo

Post by Bennettman »

Here's the code to a hoax listing page I'm trying to make. It's meant to be an upload-file-and-forget job so it'll recognise and insert them automatically. Anyway, as far as I can see, the problem's with the "$meh" value, which is just a temp value for the rest of the stuff to use. Before I added the code to stop it from making dead links for images that weren't there, it made <img> tags with the filename being "-19" and going up one number each time (which leads me to believe it's a problem with my arithmetics, I need to get used to that sometime ;p) Finally, there's no parse errors or anything coming up. Anyone know what my problem is?

Code: Select all

&lt;?php
$meh = 1;
$root = ("images/hoaxes");

print ("Page:&amp;nbsp;");
if ($page != 1) {
print ("&lt;a href="http://www.w00ty.com/tisoft/v3/index.php?section=hoaxes&amp;content=hoaxes_hoaxes&amp;id=$id&amp;page=1"&gt;1&lt;/a&gt;"); }
else {
print ("1"); }

while ((file_exists("$root/$id/($meh*20+1).gif")) || (file_exists("$root/$id/($meh*20+1).jpg")) || (file_exists("$root/$id/($meh*20+1).png") )){
print ("&amp;nbsp;");
if ($page != ($meh+1)) {
print ("&lt;a href="http://www.w00ty.com/tisoft/v3/index.php?section=hoaxes&amp;content=hoaxes_hoaxes&amp;id=$id&amp;page=($meh+1)"&gt;($meh+1)&lt;/a&gt;"); }
else {
print ($meh+1); }
$meh = ($meh + 1);
}

print ("&lt;br&gt;&lt;br&gt;");

$meh = ($page * 20 - 19);

while ($meh &lt;= ($page*20)) {
if (file_exists("$root/$id/$meh.gif")) {
$type = ("gif"); }
elseif (file_exists("$root/hoaxes/$id/$meh.jpg")) {
$type = ("jpg"); }
elseif (file_exists("$root/hoaxes/$id/$meh.png")) {
$type = ("png"); }
if (isset($type)) {
print ("&lt;img src="$root/$id/$meh.$type"&gt;&lt;br&gt;&lt;br&gt;"); }
$meh = ($meh + 1); }

?&gt;
Bennettman
Forum Contributor
Posts: 130
Joined: Sat Jun 15, 2002 3:58 pm

Post by Bennettman »

No matter, I've fixed it...
Post Reply