icon Get the most out of Surmunity, read our tips here! Need an interesting blog to read? You've got to read the Surpass Blog! | Welcome! Please register to access all of our features.

» Surpass Web Hosting Forums » Discussions » PHP, MySQL » php Get going crazy

PHP, MySQL General PHP questions. Or go to our PHPsuexec Forum >>

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread
Old July 21st, 2008, 10:55 AM   #1 (permalink)
Registered User
Fresh Surpasser
 
Joined in Dec 2005
15 posts
Gave thanks: 5
Thanked 0 times
Unhappy php Get going crazy

Ok,I learned a little bit about php $Get and opendir recently.tested it and it worked like a charm and everything was happy.
I tooka break for like a week and came back online and saw the page was full of errors,don't know what happened.

The function works on some lines and not on others,don't know why but its making me yank my hair out

here is the link to it:http://www.dollnation.org/dollmakers...elf-doll-maker

and here is the code of it:
Quote:

Welcome <?php echo $_GET["id"]; ?>.<br />
<?php echo"<img border='0' src='./$id/maker.gif'>";?>

<?php
$dir_path = "./$id/body";
$id = $_GET['id'];
$dir_list = array();
if ($handle = opendir($dir_path)) {
while ($files = readdir($handle)) {
if (preg_match("/^\./",$files)==0) $dir_list[] = $files;
}
closedir($handle);
asort($dir_list);
foreach ($dir_list as $value) {
echo"<img border='0' src='$dir_path/$value'>";
echo"&nbsp;";
}

}

?>

<?php
$dir_path = "./$id/body";
$id = $_GET['id'];
$dir_list = array();
if ($handle = opendir($dir_path)) {
while ($files = readdir($handle)) {
if (preg_match("/^\./",$files)==0) $dir_list[] = $files;
}
closedir($handle);
asort($dir_list);
foreach ($dir_list as $value) {
echo"<img border='0' src='$dir_path/$value'>";
echo"&nbsp;";
}

}

?>
<?php
$dir_path = "./$id/body";
$id = $_GET['id'];
$dir_list = array();
if ($handle = opendir($dir_path)) {
while ($files = readdir($handle)) {
if (preg_match("/^\./",$files)==0) $dir_list[] = $files;
}
closedir($handle);
asort($dir_list);
foreach ($dir_list as $value) {
echo"<img border='0' src='$dir_path/$value'>";
echo"&nbsp;";
}

}

?>
<?php echo"<img border='0' src='./$id/maker.gif'>";?>

Please help me and I will love you forever?
__________________
Server: Sh83
pogogal is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old July 21st, 2008, 11:21 AM   #2 (permalink)
Registered User
Seasoned Poster
 
Joined in Aug 2004
Lives in Endwell, New York
Hosted on Dedicated
68 posts
Gave thanks: 9
Thanked 6 times
First issue I see is you never set $id before using it. Reverse lines 5 and 6 so it is:

$id = $_GET['id'];
$dir_path = "./$id/body";

instead of:

$dir_path = "./$id/body";
$id = $_GET['id'];
__________________
Matt Rydzik
http://coaster-net.com "Your Guide to the World of Extreme Thrills!"
COASTER-net Dedicated:

Last edited by CoasterBGW; July 21st, 2008 at 11:26 AM..
CoasterBGW is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
This user thanks CoasterBGW for this great post!
pogogal (July 21st, 2008)
Old July 21st, 2008, 12:06 PM   #3 (permalink)
Surpass Developer
Excelling Contributor
 
Mark's Avatar
 
Joined in Jan 2004
Lives in Florida
Hosted on decc.surpasshosting.com
511 posts
Gave thanks: 20
Thanked 78 times
You need to sanitize $id also. If it is going to be a number, the easiest way of doing it is:

$id = (int)$_GET['id'];
__________________
Mark
Surpass Hosting Developer
sɹnoʎ uɐɥʇ ɹǝʇʇǝq sı bıs ʎɯ
Mark is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
This user thanks Mark for this great post!
pogogal (July 21st, 2008)
Old July 21st, 2008, 12:16 PM   #4 (permalink)
Registered User
Fresh Surpasser
 
Joined in Dec 2005
15 posts
Gave thanks: 5
Thanked 0 times
OMG I love you guys,My problem is Solved
__________________
Server: Sh83
pogogal is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On