Reply
why this code dont work ?!
Old 05-19-2007, 11:37 AM why this code dont work ?!
Junior Talker

Posts: 2
why this code dont work ?!
PHP Code:
<? if($lang=='eng'){
if(
file_exists("engfiles/".$_GET['pn'].".php"))
 include (
"engfiles/".$_GET['pn'].".php");
 else include(
"engfiles/right.php");
}
elseif(
$lang=='rus'){
if(
file_exists("rusfiles/".$_GET['pn'].".php"))
include (
"rusfiles/".$_GET['pn'].".php");
else include(
"rusfiles/right.php");
}
else{
if(
file_exists("files/".$_GET['pn'].".php"))
include (
"files/".$_GET['pn'].".php");
else include(
"files/right.php");
}
?>
Can any one help me ?
roobikgm is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
     
Old 05-19-2007, 11:55 AM Re: why this code dont work ?!
solomongaby's Avatar
Webmaster Talker

Latest Blog Post:
How Do You Find Music Online ?
Posts: 522
Name: Gabe Solomon
Location: Romania
a few sugestions :
- use { on all if clause
- put an echo on each if .. and else to see where it stops ..
__________________
If you like my posts ... TK is appreciated:)
Web Directory | Blog
solomongaby is offline
Reply With Quote
View Public Profile Visit solomongaby's homepage!
 
Old 05-19-2007, 01:29 PM Re: why this code dont work ?!
damien_ls's Avatar
Ultra Talker

Posts: 431
Name: Damien
Another good idea would be to explain what the code does, and what you want it to do - unless there's an obvious syntax error then there's very little chance that we can help without more detail from you.

Personally, I'd probably rewrite your code to use a switch statement on $lang as it would be a bit more readable that way - personal preference though...

I would also suggest that using $_GET['pn'] in that context without validation prior to that may be dangerous, so unless you're already validating to make sure it contains the data you expect it may be a good idea to add that to your code. Difficult to say what validation you should perform without knowing more about the context.
__________________
Layershift :: DDS & Dedicated, UK & USA-based Managed Virtuozzo VPS, Reseller & Shared Hosting
Experienced Parallels Platinum Partners (Plesk since 2001, Virtuozzo since 2004)
damien_ls is offline
Reply With Quote
View Public Profile
 
Old 05-19-2007, 01:52 PM Re: why this code dont work ?!
solomongaby's Avatar
Webmaster Talker

Latest Blog Post:
How Do You Find Music Online ?
Posts: 522
Name: Gabe Solomon
Location: Romania
good ideea damian
Quote:
switch ($lang) {
case 'eng' : $folder='engfiles'; break;
case 'rus' : $folder='rusfiles'; break;
default : $folder='files'; break;
}
if(file_exists($folder."/".$_GET['pn'].".php")){
include (
$folder."engfiles/".$_GET['pn'].".php");
} else {
include(
$folder."/right.php");
}
__________________
If you like my posts ... TK is appreciated:)
Web Directory | Blog
solomongaby is offline
Reply With Quote
View Public Profile Visit solomongaby's homepage!
 
Reply     « Reply to why this code dont work ?!
 

Thread Tools

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

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




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.14429 seconds with 13 queries