Jump to content

code not working properly


swapnali_s230

Recommended Posts

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;

elseif ($course=='ABC 33') echo $course;

elseif ($course=="VVV 34") echo $course;

elseif ($course=="CCC 95") echo $course;

elseif ($course=="MMM 12") echo $course;

elseif ($course=="OOO 89") echo $course;

elseif ($course=="CCC 75") echo $course;

}}

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.....

Link to comment
Share on other sites

get rid of the @ symbol at the start of this line:

@$course=mysql_result($sql, 0) or die('wrong query'.mysql_error()); 

you are only pulling a single result into $cource from your mysql_query() result set that is returned from the database.  You need to use a loop to itterate through the resultset array ($sql in this case) and allow you access to each row, not just the first one.

Link to comment
Share on other sites

  • 2 weeks later...

Thank you very much for reply.... The problem got solved...I used trim function. :)

I have another problem here. My mysql query is not working ..I don't know why? Here is that line -

$query =mysql_query("SELECT Course_ID FROM Course where Student_ID='$Stud_ID' AND Course_Name='COSC 3312' AND Course_Name='COSC 2430'");

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.