/    Sign up×
Community /Pin to ProfileBookmark

Problem with setting variable in elseif and echoing it

I have a search engine where users can choose consoles using checkboxes, this means that there are several combinations of console.

eg. PC, PS3, Xbox 360, PS2, Xbox, Mac.

I tried the below code but it doesn’t work

[code=php] if($pc == “on”) {
$pcsites = “&Realm=pc-cheats-codes.com&”;
}
else {
$pcsites = “”;
}

if($ps3 == “on”) {
$ps3sites = “”;
}
else {
$ps3sites = “”;
}

if($x360 == “on”) {
$x360sites = “”;
}
else {
$x360sites = “”;
}

if($ps2 == “on”) {
$ps2sites = “&Realm=playstation2cheats.net&”;
}
else {
$ps2sites = “”;
}

if($xbox == “on”) {
$xboxsites = “”;
}
else {
$xboxsites = “”;
}

if($mac == “on”) {
$macsites = “&Realm=maccheats&”;
}
else {
$macsites = “”;
}

if(isset($Terms)) {

if($Rank == “”){
echo file_get_contents(“http://www.gameslayer.co.uk/search/search.pl?Terms=’ . $Terms . ‘ . $pcsites . ‘ . $ps3sites . ‘ . $x360sites . ‘ . $ps2sites . ‘ . $xboxsites . ‘ . $macsites . ‘Match=” . $Match . “&maxhits=” . $maxhits . “&Rank=1”);
}

else {
echo file_get_contents(“http://www.gameslayer.co.uk/search/search.pl?Terms=’ . $Terms . ‘ . $pcsites . ‘ . $ps3sites . ‘ . $x360sites . ‘ . $ps2sites . ‘ . $xboxsites . ‘ . $macsites . ‘Match=” . $Match . “&maxhits=” . $maxhits . “&Rank=” . $Rank);
}

}
[/code]

The idea of the code is that the search scrip i use uses $Realm for each individual group of pages, in my case many for each site, which are then searched based pn console.

I need to set multiple Realms for a site for each console, the above code in theory works, but does not, the seardch engine responds with nothing set.

Anyone know how to make it work, alternatives?

(I havn’t shown the retriefval of $pc etc from the URL, but it has been done)

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@ChazzlMay 21.2008 — Double check that [I]$pc[/I] variable equals what you expect it to. Try [I]exit( var_dump($pc) );[/I] before the [I]if[/I] statement. Remove the code when you're done diagnosing the outcome.

It's possible it doesn't equal 'on' when expected to.

[code=php]exit( var_dump($pc) );
if($pc == "on") {
$pcsites = "&Realm=pc-cheats-codes.com&";
}
else {
$pcsites = "";
}[/code]
Copy linkTweet thisAlerts:
@ChazzlMay 21.2008 — [B]This part won't work:[/B]
[code=php]echo file_get_contents("http://www.gameslayer.co.uk/search/search.pl?Terms=' . $Terms . ' . $pcsites . ' . $ps3sites . ' . $x360sites . ' . $ps2sites . ' . $xboxsites . ' . $macsites . 'Match=" . $Match . "&maxhits=" . $maxhits . "&Rank=1");[/code]

[B]Try:[/B]
[code=php]echo file_get_contents("http://www.gameslayer.co.uk/search/search.pl?Terms=" . $Terms . $pcsites . $ps3sites . $x360sites . $ps2sites . $xboxsites . $macsites . "Match=" . $Match . "&maxhits=" . $maxhits . "&Rank=1");[/code]
Copy linkTweet thisAlerts:
@danpoultonauthorMay 21.2008 — thanks for all your help all working now ?.
Copy linkTweet thisAlerts:
@ChazzlMay 21.2008 — Awesome, gratz.

Happy coding. ?
×

Success!

Help @danpoulton spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...