/    Sign up×
Community /Pin to ProfileBookmark

php code not working

Hi All
I have been working on one program.. Its giving me output for some echo, not for other echos. I dont know why? Following is the code –

if (is_array(@$_REQUEST[‘classes’]))
{
foreach($_
REQUEST[‘classes’] as $course1) {
$sql=mysql_query(“SELECT Ma_CoName FROM MCourse where Ma_CoNo=’$course1′”);
@$course=mysql_result($sql, 0) or die(‘wrong query’.mysql_error());

if ($course==’ENGL 1301′) echo $course;
[B]elseif ($course==’MATH 3301′) echo $course;

elseif ($course==”COSC 3420″) echo $course;
elseif ($course==”COSC 4395″) echo $course;
elseif ($course==”MATH 1324″) echo $course;
elseif ($course==”COSC 3312″) echo $course;
elseif ($course==”COSC 4330″) echo $course;[/B]

}}
Code in bold is not giving me any output, but $course==’ENGL 1301′ is giving me output. I dont know why? It is so weird…..

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@WolfShadeMar 20.2012 — Odd.. but try this:

if ($course=='ENGL 1301') { echo $course; }

elseif ($course=='MATH 3301') { echo $course; }

elseif ($course=='COSC 3420') { echo $course; }

elseif ($course=='COSC 4395') { echo $course; }

elseif ($course=='MATH 1324') { echo $course; }

elseif ($course=='COSC 3312') { echo $course; }

elseif ($course=='COSC 4330') { echo $course; } // don't forget to change all " to ', just in case

I'm assuming this is so that only certain $course values are displayed? If not, why not just have the one echo?

Also, are you checking to make sure that the value is trimmed, as in your condition?
Copy linkTweet thisAlerts:
@swapna10authorMar 21.2012 — I have changed " to ' , but still same thing happening - no output.

I am not checking whether value is trimmed or not. How will I do it?

Thanks
Copy linkTweet thisAlerts:
@swapna10authorMar 21.2012 — Hey Wolfshade, Thanks for Trimming suggestion.. It worked.. million Thanks?
×

Success!

Help @swapna10 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 6.18,
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: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

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