webguync Posted April 6, 2009 Share Posted April 6, 2009 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 https://forums.phpfreaks.com/topic/152883-solved-need-help-spotting-the-error/ Share on other sites More sharing options...
taquitosensei Posted April 6, 2009 Share Posted April 6, 2009 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 https://forums.phpfreaks.com/topic/152883-solved-need-help-spotting-the-error/#findComment-802883 Share on other sites More sharing options...
webguync Posted April 6, 2009 Author Share Posted April 6, 2009 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 https://forums.phpfreaks.com/topic/152883-solved-need-help-spotting-the-error/#findComment-802898 Share on other sites More sharing options...
premiso Posted April 6, 2009 Share Posted April 6, 2009 You have two ORDER BY's in your sql query. Alternatively, using mysql_query would have pointed this out. $result = mysql_query("SELECT * FROM TableName ORDER BY employee_id, date_created ASC") or die(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/152883-solved-need-help-spotting-the-error/#findComment-802903 Share on other sites More sharing options...
webguync Posted April 6, 2009 Author Share Posted April 6, 2009 doh! thanks, I should have seen that. Link to comment https://forums.phpfreaks.com/topic/152883-solved-need-help-spotting-the-error/#findComment-802907 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.