Jump to content

help error in code!!


gammaman

Recommended Posts

What is wrong with this code, when I execute it I get a blank page.

 

$conn=mysql_connect("localhost","fierm","13183");

if (!$conn){
    echo "failed";
}else{

mysql_select_db("fierm");
  
session_start();
   echo "here";
   $_SESSION['student']['user'];
   $_SESSION['student']['pass'];
   echo '<table border = "1">';
   $result=mysql_query("select CourseID,CourseName,StudentID,Grade FROM Rcourse WHERE StudentID='{$_SESSION['student']['user']}'");
   $cou=mysql_num_rows($result);
   if ($cou==0){
      echo "Not in Any Courses";
   }
   else{
   echo "<tr><th>CourseID</th><th>CourseName</th><th>Grade<th>Drop Course</th></tr>";
     
   while ($row=mysql_fetch_array($result))
   {
     $CourseID = $row['CourseID'];
     $grade = $row['Grade'];
     $result1=mysql_query("SELECT * FROM Course WHERE CourseID='$CourseName'");
     $r=mysql_fetch_array($result1);
     $course=$r['CourseName'];
     if (ltrim ($grade) = ""){
           $value "---";
     }
     else{ 
          $value='<a href = \"checkStuDrop?cid='.$CourseID.'">Drop</a>';  
           
   }
       echo "<tr><td>$CourseName</td><td>$course</td><td>$value</td></tr>";
   }
   }
   echo "</table>";

 

           

   

 

 

 

 

Link to comment
Share on other sites

try this

<?php
mysql_select_db("fierm");

session_start();
   echo "here";
   $_SESSION['student']['user'];
   $_SESSION['student']['pass'];
   echo '<table border = "1">';
   $result=mysql_query("select CourseID,CourseName,StudentID,Grade FROM Rcourse WHERE StudentID='{$_SESSION['student']['user']}'");
   $cou=mysql_num_rows($result);
   if ($cou==0){
      echo "Not in Any Courses";
   }
   else{
   echo "<tr><th>CourseID</th><th>CourseName</th><th>Grade<th>Drop Course</th></tr>";

   while ($row=mysql_fetch_array($result))
   {
     $CourseID = $row['CourseID'];
     $grade = $row['Grade'];
     $result1=mysql_query("SELECT * FROM Course WHERE CourseID='$CourseName'");
     $r=mysql_fetch_array($result1);
     $course=$r['CourseName'];
     if (ltrim ($grade) == ""){  // 2 equals signs here
           $value = "---";  // forgot your equal sign here
     }
     else{
          $value='<a href = \"checkStuDrop?cid='.$CourseID.'">Drop</a>';

   }
       echo "<tr><td>$CourseName</td><td>$course</td><td>$value</td></tr>";
   }
   }
   echo "</table>";


?>

 

Ray

Link to comment
Share on other sites

<?php
$conn=mysql_connect("localhost","fierm","13183");

if (!$conn){
    echo "failed";
}else{

mysql_select_db("fierm");
  
session_start();
   echo "here";
   $_SESSION['student']['user'];
   $_SESSION['student']['pass'];
   echo '<table border = "1">';
   $result=mysql_query("select CourseID,CourseName,StudentID,Grade FROM Rcourse WHERE StudentID='{$_SESSION['student']['user']}'");
   $cou=mysql_num_rows($result);
   if ($cou==0){
      echo "Not in Any Courses";
   }
   else{
   echo "<tr><th>CourseID</th><th>CourseName</th><th>Grade<th>Drop Course</th></tr>";
     
   while ($row=mysql_fetch_array($result))
   {
     $CourseID = $row['CourseID'];
     $grade = $row['Grade'];
     $CourseName = $row['CourseName']; //verify that this is accurate
     $result1=mysql_query("SELECT * FROM Course WHERE CourseID='$CourseName'");
     $r=mysql_fetch_array($result1);
     $course=$r['CourseName'];
     if (ltrim($grade) == ""){
           $value = "---";
     }
     else{ 
          $value='<a href = \"checkStuDrop?cid='.$CourseID.'">Drop</a>';  
           
   }
       echo "<tr><td>$CourseName</td><td>$course</td><td>$value</td></tr>";
   }
   }
   echo "</table>";
}

I posted it anways :P

Link to comment
Share on other sites

Shouldn't this

$result1=mysql_query("SELECT * FROM Course WHERE CourseID='$CourseName'");

 

be this

$result1=mysql_query("SELECT * FROM Course WHERE CourseID='$CourseID'") or die(mysql_error());

 

Add some error checking!

 

Ray

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.