west4me Posted June 19, 2006 Share Posted June 19, 2006 I had a site built for me and I had it working but something happend to the database that I was using. I either did something or something else happend.The error I get when I try to login is this:[code]Can't find file: 'classes.MYI' (errno: 2)[/code]any ideas of how to fix that? I also get that error when I view through phpmyadmin.I have a feeling I need to rebuild the database but I have no idea of how to write the .sql file. I can't reach the guy who built it. I l will list the code from all of the pages that the site uses, could someone take a look at it and write a new .sql file for me? I would be willing to make a donation for help.This is the dbconnect file:[code]<?$location = "localhost";$user = "";$password = "";$db = "";$conn = mysql_connect($location, $user, $password) or die("Could not connect to MySQL");$db = mysql_select_db($db) or die("Could not select database".mysql_error());?>[/code]This is the admin file:[code]<?php /********************************************\* ** class test administation ** copyright 2005 Phil Pedlar ** *\********************************************/session_start();if (!$_SESSION['username']) { header ("location: index.php");}include ("dbconnect.php");require_once("dbconnect.php");?><html><head><title>Test Admin</title><style>body {font: 12px verdana;}table {font: 12px verdana;}h2 {font: 16px verdana;font-weight: bold;}#results td {padding-left: 10px;padding-right: 10px;}#results td {padding-left: 5px;padding-right: 5px;}</style></head><body><span>| <a href='admin.php?add=class'>Add Class</a> | <a href='admin.php?add=student'>Add Student</a> | <a href='admin.php?add=scores'>Add Scores</a> | <a href='admin.php?show=completetests'>View Complete Tests</a> |</span><p /><?//this section is for adding a classif ($_GET["add"] == "class") { if ($_GET["add"] == "class" && $_POST["classname"]) { $classname = $_POST["classname"]; $query = mysql_query("INSERT INTO classes (`classid`, `classname`) VALUES ('', '$classname')"); print "<p>Class $classname was succesfully added to the the classes list</p>"; exit(); } print "<p>Please type in the box below which classname you would like to add to the list</p>"; print "<form method='post'> <table style='width:300px;'> <tr><td>Classname</td><td><input type='text' name='classname' /></td></tr> <tr><td></td><td><input type='submit' value='Add Class' /></td></tr> </table> </form>"; //this section is for adding a student} else if ($_GET["add"] == "student") { if ($_GET["add"] == "student" && $_POST["student_classname"] == "select") { print "<p>You did not select a class for this student</p> <p><a href='admin.php?add=student'>back</a></p>"; exit(); } else if ($_GET["add"] == "student" && $_POST["student_studentname"] && $_POST["student_classname"]) { $studentname = $_POST["student_studentname"]; $classname = $_POST["student_classname"]; $query = mysql_query("INSERT INTO students (`studentid`, `student_name`, `classname`) VALUES ('', '$studentname', '$classname')"); print "<p>Succsfully added student: $studentname to class: $classname</p>"; exit(); } print "<p>Please type the name of the student you would like to add in the box and select the classname that they belong to.</p>"; print "<form method='post'> <table style='width:300px;'> <tr><td>Student Name:</td><td><input type='text' name='student_studentname' /></td></tr> <tr><td>Student Class:</td><td> <select name='student_classname'> <option value='select' selected='selected'>Select</option>"; $query = mysql_query("SELECT * FROM classes"); while ($row = mysql_fetch_array($query)) { print "<option value='".$row["classname"]."'>".$row["classname"]."</option>"; } print " </select> </td></tr> <tr><td></td><td><input type='submit' value='Add Student' /></td></tr> </table> </form>"; } else if ($_GET["add"] == "scores") { print "<p>Please select by what you would like to add scores</p> <p><a href='admin.php?add=scores&type=individual'>By Individual</a></p>"; if ($_GET["add"] == "scores" && $_POST["add_byclass"]) { print "<h2>Please select the student you would like to add results for</h2>"; $class = $_POST["add_byclass"]; $query = mysql_query("SELECT * FROM students WHERE classname = '$class'"); print "<form method='post'> <table> <tr><td>Student</td><td> <select name='add_byname' onchange='this.form.submit();'> <option value='select' selected='selected'>Select</option>"; while ($row = mysql_fetch_array($query)) { print "<option value='".$row["student_name"]."'>".$row["student_name"]."</option>"; } print "<input type='hidden' name='student_name' value='".$row["student_name"]."' /> </table> </form>"; exit(); } if ($_GET["add"] == "scores" && $_POST["add_byname"]) { $name = $_POST["add_byname"]; $query = mysql_query("SELECT * FROM students WHERE student_name = '$name' ORDER BY student_name"); if ($row = mysql_fetch_array($query)) { print "<form method='post' action='addscores.php'> <table id='addscore' border='1'> <tr><th>Name</th><th>Class</th><th>2 x 2</th><th>3 x 3</th><th>4 x 4</th><th>5 x 5</th><th>6 x 6</th><th>7 x 7</th><th>8 x 8</th><th>9 x 9</th> <th>10 x 10</th><th>11 x 11</th><th>12 x 12</th></tr>"; do { print "<td style='width:50px;'>".$row["student_name"]."</td><td style='width:50px;'>".$row["classname"]."</td>"; print "<td><select name='add_2by2'><option value='".$row["2by2"]."'>".$row["2by2"]."</option><option value='Pass'>Pass</option><option value='Fail'>Fail</option></select></td>"; for ($n = 3; $n <= 12; $n++) { print "<td><select name=\"add_$nby$n\"><option value='".$row["$nby$n"]."'>".$row["$nby$n"]."</option><option value='Pass'>Pass</option><option value='Fail'>Fail</option></select></td>"; } print "</tr>"; } while ($row = mysql_fetch_array($query)); } print "</table>"; print "<input type='submit' name='add_class_scores' value='Add Scores' /> <input type='hidden' value='".$name."' name='student_name' /> </form>"; exit(); } print "<h2>Please select the class you would like to add results for</h2>"; $query = mysql_query("SELECT * FROM classes"); print "<form method='post'> <table> <tr><td>Student</td><td> <select name='add_byclass' onchange='this.form.submit();'> <option value='select' selected='selected'>Select</option>"; while ($row = mysql_fetch_array($query)) { print "<option value='".$row["classname"]."'>".$row["classname"]."</option>"; } print "</select></td></tr></table></form>"; // this section is for showing completed test results, by class or by individual} else if ($_GET["show"] == "completetests") { print "<p>Please select by what you would like to view scores</p> <p><a href='admin.php?show=completetests&type=class'>By Class</a><br /><a href='admin.php?show=completetests&type=individual'>By Individual</a></p>"; if ($_GET["show"] == "completetests" && $_GET["type"] == "class") { if ($_GET["show"] == "completetests" && $_GET["type"] == "class" && $_POST["results_byclass"]) { $class = $_POST["results_byclass"]; $query = mysql_query("SELECT * FROM students WHERE classname = '$class'"); if ($row = mysql_fetch_array($query)) { print "<h2>Viewing Results by Class</h2> <table id='results' border='1'> <th>Name</th><th>Class</th><th>2 x 2</th><th>3 x 3</th><th>4 x 4</th><th>5 x 5</th><th>6 x 6</th><th>7 x 7</th><th>8 x 8</th><th>9 x 9</th> <th>10 x 10</th><th>11 x 11</th><th>12 x 12</th>"; do { print "<tr><td>".$row["student_name"]."</td><td>".$row["classname"]."</td><td class='$class'>".$row["2by2"]."</td> <td class='$class'>".$row["3by3"]."</td><td class='$class'>".$row["4by4"]."</td><td class='$class'>".$row["5by5"]."</td> <td class='$class'>".$row["6by6"]."</td><td class='$class'>".$row["7by7"]."</td><td class='$class'>".$row["8by8"]."</td> <td class='$class'>".$row["9by9"]."</td><td class='$class'>".$row["10by10"]."</td><td class='$class'>".$row["11by11"]."</td> <td class='$class'>".$row["12by12"]."</td>"; } while ($row = mysql_fetch_array($query)); print "</table>"; } exit(); } $query = mysql_query("SELECT * FROM classes"); print "<p>Please select which class you would like to see the results for</p> <form method='post'> <table style='width:300px'> <tr><td style='width:30px;'>Class</td><td> <select name='results_byclass' onchange='this.form.submit();'> <option value='select' selected='selected'>Select</option>"; while ($row = mysql_fetch_array($query)) { print "<option value='".$row["classname"]."'>".$row["classname"]."</option>"; } print "</select></td></tr> </table> </form>"; } else if ($_GET["show"] == "completetests" && $_GET["type"] == "individual") { if ($_GET["show"] == "completetests" && $_GET["type"] == "individual" && $_POST["results_byind"]) { $name = $_POST["results_byind"]; $query = mysql_query("SELECT * FROM students WHERE student_name = '$name'"); if ($row = mysql_fetch_array($query)) { print "<h2>Viewing Results by Student</h2> <table id='results' border='1'> <th>Name</th><th>Class</th><th>2 x 2</th><th>3 x 3</th><th>4 x 4</th><th>5 x 5</th><th>6 x 6</th><th>7 x 7</th><th>8 x 8</th><th>9 x 9</th> <th>10 x 10</th><th>11 x 11</th><th>12 x 12</th>"; do { for ($n = 2; $n <= 12; $n++) { if ($row["$nby$n"] == "Not Taken") $class = "amber"; if ($row["$nby$n"] == "Fail") $class = "red"; if ($row["$nby$n"] == "Pass") $class = "green"; } print "<tr><td>".$row["student_name"]."</td><td>".$row["classname"]."</td><td class='$class'>".$row["2by2"]."</td> <td class='$class'>".$row["3by3"]."</td><td class='$class'>".$row["4by4"]."</td><td class='$class'>".$row["5by5"]."</td> <td class='$class'>".$row["6by6"]."</td><td class='$class'>".$row["7by7"]."</td><td class='$class'>".$row["8by8"]."</td> <td class='$class'>".$row["9by9"]."</td><td class='$class'>".$row["10by10"]."</td><td class='$class'>".$row["11by11"]."</td> <td class='$class'>".$row["12by12"]."</td>"; } while ($row = mysql_fetch_array($query)); print "</table>"; exit(); } } $query = mysql_query("SELECT * FROM students"); print "<form method='post'> <table> <tr><td>Student</td><td> <select name='results_byind' onchange='this.form.submit();'> <option value='select' selected='selected'>Select</option>"; while ($row = mysql_fetch_array($query)) { print "<option value='".$row["student_name"]."'>".$row["student_name"]."</option>"; } print "</select></td></tr> </table></form>"; } }?></body></html>[/code]This is the addscores file:[code]<?/********************************************\* ** class test administation ** copyright 2005 Phil Pedlar ** *\********************************************/require_once("dbconnect.php"); $_2by2 = $_POST["add_2by2"]; $_3by3 = $_POST["add_3"]; $_4by4 = $_POST["add_4"]; $_5by5 = $_POST["add_5"]; $_6by6 = $_POST["add_6"]; $_7by7 = $_POST["add_7"]; $_8by8 = $_POST["add_8"]; $_9by9 = $_POST["add_9"]; $_10by10 = $_POST["add_10"]; $_11by11 = $_POST["add_11"]; $_12by12 = $_POST["add_12"]; $student = $_POST["student_name"]; $query = "UPDATE students SET 2by2 = '$_2by2', 3by3 = '$_3by3', 4by4 = '$_4by4', 5by5 = '$_5by5', 6by6 = '$_6by6', 7by7 = '$_7by7', 8by8 = '$_8by8', 9by9 = '$_9by9', 10by10 = '$_10by10', 11by11 = '$_11by11', 12by12 = '$_12by12' WHERE student_name = '$student'"; mysql_query($query); print "<p>Added scores to database</p> <p><a href='admin.php'>back</p>";?>[/code]and this is the index files:[code]<?phprequire_once("dbconnect.php");session_start();if ($_POST) { $user = $_POST["username"]; $pass = md5($_POST["password"]); $query = mysql_query("SELECT * FROM login WHERE username = '$user' AND password = '$pass'")or die(mysql_error()); $row = mysql_fetch_array($query); if ($user == $row["username"] && $pass = $row["password"]) { session_register('username'); $_SESSION['username'] = $user; header ("location: admin.php"); } else { header ("location: index.php"); } }?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head profile="http://gmpg.org/xfn/11"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Multiplication Administration</title> <meta name="generator" content="WordPress 1.5.2" /> <!-- leave this for stats please --> <style type="text/css" media="screen"> </style> <link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="http://west4me.com/wordpress/?feed=rss2" /> <link rel="alternate" type="application/atom+xml" title="Atom 0.3" href="http://west4me.com/wordpress/?feed=atom" /> <link rel="pingback" href="http://west4me.com/wordpress/xmlrpc.php" /> <link rel='archives' title='October 2005' href='http://west4me.com/wordpress/?m=200510' /> <link rel='archives' title='September 2005' href='http://west4me.com/wordpress/?m=200509' /> <link href="style.css" rel="stylesheet" type="text/css" /> <style type="text/css"><!--.style2 {font-size: 16px; }.style3 {font-size: 16px; color: #676E04; }--> </style></head><body><div id="rap"> <div id="header"> <ul id="topnav"> <li><a href="http://west4me.com/moodle" id="navHome" title="Posted Recently" accesskey="h">Home</a></li> <li><a href="http://west4me.com/cal" id="navHome" title="Posted Recently" accesskey="c">Calendar</a></li> <li><a href="http://west4me.com/story2" id="navHome" title="Posted Recently" accesskey="s">Stories</a></li> <li><a href="http://west4me.com/bookmarks" id="navHome" title="Posted Recently" accesskey="b">Bookmarks</a></li> <li><a href="http://west4me.com/wordpress" id="navHome" title="Posted Recently" accesskey="w">Blog</a></li> <li><a href="http://west4me.com/webcollab/index.php" id="navHome" title="Posted Recently" accesskey="p">Writing Progress</a></li> <li><a href="http://west4me.com/kidscms/index.php" id="navHome" title="Posted Recently" accesskey="f">Student Pages</a></li> <li><a href="http://west4me.com/daily/name.php" id="navHome" title="Posted Recently" accesskey="f">Name Draw</a></li> <li><a href="http://west4me.com/daily/job2.php" id="navHome" title="Posted Recently" accesskey="f">Jobs</a></li> <li><a href="http://west4me.com/daily/lunch.php" id="navHome" title="Posted Recently" accesskey="f">Lunch Choice</a></li> <li><a href="http://west4me.com/daily/" id="navHome" title="Posted Recently" accesskey="f">Daily</a></li> </ul> <h1><a href="http://west4me.com/daily" title=""></a></h1> <div id="desc">Classroom Schedule</div></div> <div id="main"> <div id="content"> <div class="post"> <div class="post-info"><h2 class="post-title">Welcome to another wonderful day!</a></h2> <p>Make sure you take care of all your morning tasks before the bell rings.</p> </div><div class="post-content"> <form name='login' method='POST'><table style='width:300px;'> <tr><td>Username</td><td><input type='text' name='username' /></td></tr> <tr><td>Password</td><td><input type='password' name='password' /></td></tr> <tr><td></td><td><input type='submit' value='Login' /></td></tr></table> <div id="content"></div> <p> </p></div> </div> <p align="center"></p> </div> <p id="footer"><a href="http://www.west4me.com/moodle" title="Cunningham">Mr. Cunningham's Classroom</a></p></div></div></body></html>[/code]Please any help would be appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/12352-help-rebuild-from-code/ Share on other sites More sharing options...
Ninjakreborn Posted June 19, 2006 Share Posted June 19, 2006 You are using tables, whoever built it was slow, because it makes it harder to read, I don't see any obvious syntax errors, and there is no includes trying to include that file, a search of google for errors related to sql in that form come up with this telling me it has something to do with a table error, so maybe your database itself has an error in it, if so debug it using phpmyadmin, maybe there is a possibility someone fed you bad data, it could have been a lot of things.Go to www.google.com and search .myiit will fill you in on all possible information relating to your error, here is the first entry there.[a href=\"http://www.modwest.com/help/kb6-230.html\" target=\"_blank\"]http://www.modwest.com/help/kb6-230.html[/a] Quote Link to comment https://forums.phpfreaks.com/topic/12352-help-rebuild-from-code/#findComment-47394 Share on other sites More sharing options...
fenway Posted June 20, 2006 Share Posted June 20, 2006 No need to [a href=\"http://www.phpfreaks.com/forums/index.php?showtopic=96254\" target=\"_blank\"]double-post[/a]. Quote Link to comment https://forums.phpfreaks.com/topic/12352-help-rebuild-from-code/#findComment-47652 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.