Jump to content

[SOLVED] need help spotting the error


webguync

Recommended Posts

Hi,

 

I have an error somewhere in my code, which produces a blank white page. I don't have access to the .ini file to change the error reporting, so was hoping someone could spot it. It might be obvious and I am just not seeing it.

 

<?php
$con = mysql_connect("localhost","username","pw");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("DBName", $con);


$result = mysql_query("SELECT * 
		FROM tablename ORDER BY ORDER BY employee_id, date_created ASC");
$count = 0;
$CallNumber = 1;

while($row = mysql_fetch_array($result))
  {

$currentID = $row['employee_id'];

    if($count == 0 || $currentID != $previousID)
        $CallNumber = 1;
    else
        $CallNumber++;

  echo "<tr>";
  echo "<td>" . $row['score_id'] . "</td>";
  echo "<td>" . $row['employee_id'] . "</td>";
  echo "<td>" . $row['employee_name'] . "</td>";
  echo "<td>" . $row['score1'] . "</td>";
  echo "<td>" . $row['score2'] . "</td>";
  echo "<td>" . $row['score3'] . "</td>";
  echo "<td>" . $row['score4'] . "</td>";
  echo "<td>" . $row['score5'] . "</td>";
  echo "<td>" . $row['score6'] . "</td>";
  echo "<td>" . $row['assessor_name'] . "</td>";
  echo "<td>" . $row['assessor_id'] . "</td>";
  echo "<td>" . $CallNumber . "</td>";
  echo "<td>" . $row['date_created'] . "</td>";
  echo "<td>" . $row['date_uploaded'] . "</td>";
  echo "</tr>";

$previousID = $currentID;
    
    $count++;

  }

mysql_close($con);

?>


Link to comment
Share on other sites

I think you forgot brackets here

    if($count == 0 || $currentID != $previousID)
        $CallNumber = 1;
    else
        $CallNumber++;

should be


    if($count == 0 || $currentID != $previousID) {
        $CallNumber = 1;
}
    else {

}

plus you can change error reporting by adding this

ini_set("display_errors","1");
ERROR_REPORTING(E_ALL);

to the top of your page

 

        $CallNumber++;

Link to comment
Share on other sites

thanks, I added the brackets, and still get an error. With the error reporting, I now know what the error is:

 

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /var/www/vhosts/etsi-dataservices.com/httpdocs/NNPrinceton/Jan09/report/Individual_Scores.php on line 27

 

my current code is:

 

<?php
ini_set("display_errors","1");
ERROR_REPORTING(E_ALL);
$con = mysql_connect("localhost","username","pw");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("DBName", $con);


$result = mysql_query("SELECT * 
		FROM TableName ORDER BY ORDER BY employee_id, date_created ASC");
$count = 0;
$CallNumber = 1;

while($row = mysql_fetch_array($result))
  {

$currentID = $row['employee_id'];

    if($count == 0 || $currentID != $previousID) {
        $CallNumber = 1; }
    else {
        $CallNumber++;
	}

  echo "<tr>";
  echo "<td>" . $row['score_id'] . "</td>";
  echo "<td>" . $row['employee_id'] . "</td>";
  echo "<td>" . $row['employee_name'] . "</td>";
  echo "<td>" . $row['score1'] . "</td>";
  echo "<td>" . $row['score2'] . "</td>";
  echo "<td>" . $row['score3'] . "</td>";
  echo "<td>" . $row['score4'] . "</td>";
  echo "<td>" . $row['score5'] . "</td>";
  echo "<td>" . $row['score6'] . "</td>";
  echo "<td>" . $row['assessor_name'] . "</td>";
  echo "<td>" . $row['assessor_id'] . "</td>";
  echo "<td>" . $CallNumber . "</td>";
  echo "<td>" . $row['date_created'] . "</td>";
  echo "<td>" . $row['date_uploaded'] . "</td>";
  echo "</tr>";

$previousID = $currentID;
    
    $count++;

  }

mysql_close($con);

?>

 

 

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.