0

After i truncate some table in my database I cannot select a specific column in my table which is not affected by the truncate code. I think my database has been corrupted. My final defense is 2 days from now and we already completed the system but after running this code my system went crazy! Because select function functioning properly here is the code that I think literally destroy my database, it is use to reset the evaluation system of a particular university.

mysql_query("TRUNCATE TABLE records");

mysql_query("TRUNCATE TABLE chairassign");

mysql_query("TRUNCATE TABLE studentstotal");

mysql_query("TRUNCATE TABLE tempfiles");

mysql_query("TRUNCATE TABLE tempfiles2");

mysql_query("UPDATE evaluationstatus SET allowviewing ='NO'");

mysql_query("UPDATE faculty SET EvaluateID1 = 'NULL', EvaluateID2 = 'NULL', EvaluateID3 = 'NULL' , EvaluatedbySelf = 'NO' ,canEvaluate = 'NO'");

mysql_query("UPDATE users SET DeanEvaluator = 'NO' ,EvaluatedbySelf = 'NO' ,EvaluatedbyDean = 'NO'");

When I try to select

$faculty = mysql_query("SELECT * FROM faculty WHERE DepartmentID = '$myDepartment'");

it shows up none even though I am pretty sure their is data in the table faculty

  • 1
    Please, [stop using `mysql_*` functions](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php). They are no longer maintained and are [officially deprecated](https://wiki.php.net/rfc/mysql_deprecation). Learn about [prepared statements](http://en.wikipedia.org/wiki/Prepared_statement) instead, and consider using PDO, [it's not as hard as you think](http://jayblanchard.net/demystifying_php_pdo.html). – Jay Blanchard May 29 '15 at 12:20
  • I'l take note of that after testing I found out that there is only 1 specific column I cannot select and that is the problem I dont know what happen I am pretty sure that the naming convention is correct – Salvador Mark Anjelo May 29 '15 at 12:22
  • If you need to make changes to your post click 'edit' and make the changes instead of posting them to the comments. – Jay Blanchard May 29 '15 at 12:23
  • sorry I am new here but thanks for the advice – Salvador Mark Anjelo May 29 '15 at 12:24
  • If you go look in the faculty table do you see data there? – Jay Blanchard May 29 '15 at 12:25
  • yes particularly a specific column name DepartmentID cannot be selected after i run the code I don't know what happened thanks for having the patience to help – Salvador Mark Anjelo May 29 '15 at 12:28
  • Try running the query without specifying a department id – Jay Blanchard May 29 '15 at 12:33
  • I tried and it displays all list of faculty and their information I find it very weird that only that column is not working jeez – Salvador Mark Anjelo May 29 '15 at 12:34
  • TRUNCATE TABLE empties a table completely. Logically, this is equivalent to a DELETE statement that deletes all rows. https://dev.mysql.com/doc/refman/5.0/en/truncate-table.html – Zast May 29 '15 at 12:56
  • The OP is not TRUNCATING the faculty table. – Jay Blanchard May 29 '15 at 12:59

1 Answers1

0

After taking sometime I decided to drop all the contents of faculty table and upload a new csv seems to work like a charm I think the columns mismatch when I Update some columns in the faculty table above (feeling relieved) I'l be careful next time thanks for the help