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
https://forums.phpfreaks.com/topic/102336-help-error-in-code/
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
https://forums.phpfreaks.com/topic/102336-help-error-in-code/#findComment-523992
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
https://forums.phpfreaks.com/topic/102336-help-error-in-code/#findComment-523993
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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