|
-
Oct 8th, 2004, 09:39 PM
#1
Thread Starter
Fanatic Member
[Solved] Splitting Query String
Dunno if my question meets my needs here.
I'm having problem with this code
Code:
$code=$_GET['code'];
echo $code;
$col=split('.',$code);
if($col[1]=='vb'){
$h->vb_file("source/".$code);
}
else if($col[1]=='cs'){
$h->csharp_file("source/".$code);
}
else if($col[1]=='php'){
highlight_file("source/".$code);
}
It echoes the $code (highlight.php) say I have showcode.php?code=highlight.php, but... it doesn't go through the if's. Am I missing something?
Last edited by brown monkey; Oct 9th, 2004 at 03:01 AM.
-
Oct 8th, 2004, 09:58 PM
#2
Addicted Member
Why don't you put a debugging echo statement in your if cases to see which case is true? The problem may lie in your function call inside the successful if.
Circa 1995
Engineer - I think we should put our website address on our paper catalogs.
Vice President - Don't get too excited about this internet thing.
I am sorry, but the Oracle was mistaken. You cannot help us.
-Matrix video game
I'm doing a (free) operating system (just a hobby, won't be big and professional like gnu) for 386(486) AT clones. ... and it probably never will support anything other than AT-harddisks, as that's all I have :-(.
-Linus
Question. Do you know that the character "?" means I'm asking a question? Question. Do you know that spoken inflection also provides the same cue? So please don't say, "Question" before you ask your question. Believe me I'll know.
That said, I would have said this first if it had to precede what I'm telling you now. Having said that, what I'm telling you now is the same thing I just said about the annoying phrases "That said" and "Having said that".
Are you threatening me, Master Jedi?
-Chancellor Palpatine
-
Oct 8th, 2004, 10:02 PM
#3
Thread Starter
Fanatic Member
Thanks for the reply. The problem is neither of the three if is true. And even $col is something of a Nothing;
PHP Code:
$code=$_GET['code'];
echo $code; // prints highlight.php
$col=split(".",$code);
echo $col[0]; // prints nothing
if($col[1]=='vb'){
echo "hello world"; // not executed
$h->vb_file("source/".$code);
}
else if($col[1]=='cs'){
echo "hello world"; // not executed
$h->csharp_file("source/".$code);
}
else if($col[1]=='php'){
echo "hello world"; // not executed
highlight_file("source/".$code);
}
-
Oct 9th, 2004, 02:58 AM
#4
From PHP.Net
split -- Split string into array by regular expression
The regular expression "." matches any non newline character, so you'll just get an array full of blanks. Use the explode() function instead.
-
Oct 9th, 2004, 03:00 AM
#5
Thread Starter
Fanatic Member
A very big Thank you... Pensi Master.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|