Tuscanbot Posted November 1, 2013 Share Posted November 1, 2013 Hi guys, I've encountered strange issue, my memberadd, log in, registration and others works fine however for the memberaddprocess file, it says the table doesn't exist. It says Unable to execute query. Error code1146:Table '******_db.member' doesn't exist This is really weird, does anyone ever encounter this? bellow is my code for memberadd and the one after is the memberaddprocess which it says that it doesn't found the table. <?php session_start(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/chtml-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en" > <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta name="description" content="Web Programming :: Assignment 2" /> <meta name="Keywords" content="Web, programming" /> <title>Member Login</title> </head> <body> <h1>My Member System</h1> </body> </html> <?php require_once('sqlconnect.inc.php'); if(isset($_SESSION['membername'] )) { echo "<p>Add Member Page". "<br />".$_SESSION['membername']."</p>"; $conn = @mysqli_connect($host, $user, $pswd, $dbnm); if (!$conn) { echo "<p>Database connection failure</p>"; } else { @mysqli_select_db($conn, $dbnm) or die ("Database not available"); } $memberHid = $_SESSION['membername']; $query = "SELECT member_name FROM team"; $result = mysqli_query($conn, $query); if(!$result) { echo "<p>Query failed to execute, Error with: ", $query, "</p>"; } $queryFetch = mysqli_fetch_row($result); //echo "<p> $queryResult1</p>"; $m=0; while($queryFetch) { $mQueryFetch[$m] = $queryFetch[0]; $queryFetch = mysqli_fetch_row($result); $m++; } $i=0; $query2 = "SELECT member_id FROM team WHERE member_name='$memberHid'"; $result2 = @mysqli_query($conn, $query2); $queryFetchResult = mysqli_fetch_row($result); $memId = $queryFetchResult[0]; $query3 = "SELECT COUNT(*) FROM myteam WHERE member_id1 = '$memId'"; //query for counting the no of friends $resultSelect = @mysqli_query($conn,$query3) or die ("<p>Query failed to execute.</p>". "<p>Error with:" . mysqli_errno($conn) .":" . mysqli_error($conn))."</p>"; $arCount = mysqli_fetch_row($resultSelect); echo "<p>Number of Current team member is"." ". $arCount[0]." "."</p>"; $querySelect = "SELECT member_id2 FROM myteam WHERE member_id1 = '$memId'"; $resultSelect2 = @mysqli_query($conn, $querySelect); $memArr = mysqli_fetch_row($resultSelect2); if($memArr) { while($memArr) { foreach($memArr as $value) { $querySelect3 = "SELECT member_name FROM team WHERE member_id = '$value'"; $queryResult = @mysqli_query($conn,$querySelect3); $fetchArr = mysqli_fetch_row($queryResult); foreach($fetchArr as $value) { $newDat[$a] = $value; $a++; } } $memArr = mysqli_fetch_row($resultSelect2); } $curLog = array_diff($mQueryFetch, $newDat); //for displaying profile names without the currently logged in user and his old friends profile names $querySelect2 = "SELECT member_name FROM team"; $querySelectResult = @mysqli_query($conn,$querySelect2) or die ("<p>Query Failed to Execute.</p>". "<p>Error with" . mysqli_errno($conn) .":" . mysqli_error($conn))."</p>"; echo "<table width='20%' border='1'>"; echo "<tr><th>Member Name</th>"; echo "<th>Status</th></tr>"; $fetchArray = mysqli_fetch_row($querySelectResult); foreach($diff as $value) { if($value!=$_SESSION['membername']) { echo "<tr><td>{$value}</td>"; $memberHid1 = $value; $memberHid = $_SESSION['membername']; echo "<td>"?> <form action ="memberaddprocess.php" method = "post" > <?php echo'<input type="hidden" name="memberHid1" value="'.htmlspecialchars($memberHid1).'" />';?> <?php echo'<input type="hidden" name="memberHid" value="'.htmlspecialchars($memberHid).'" />';?> <p><input type="submit" name="Addmember" value="AddMember" /></p> </form> <?php "</td></tr>"; } $fetchArray = mysqli_fetch_row($querySelectResult); } echo"</table>"; } else { $n=0; $querySelect2 = "SELECT member_name FROM team"; $querySelectResult = @mysqli_query($conn, $querySelect2) or die ("<p>Query Failed to Execute.</p>". "<p>Error with" . mysqli_errno($conn) .":" . mysqli_error($conn))."</p>"; $fetchArray = mysqli_fetch_row($querySelectResult); while($fetchArray) { if($fetchArray[0] != $_SESSION['membername']) { $name[$n] = $fetchArray[0]; $n++; } $fetchArray = mysqli_fetch_row($querySelectResult); } sort($name); echo "<table width='20%' border='1'>"; echo "<tr><th>Member Name</th>"; echo "<th>Status</th></tr>"; for($n = 0; $n<sizeof($name); $n++) { $memberHid1 = $name[$n]; $memberHid = $_SESSION['membername']; echo "<tr><td>{$memberHid1}</td>"; echo "<td>"?> <form action ="memberaddprocess.php" method = "post" > <?php echo'<input type="hidden" name="memberHid1" value="'.htmlspecialchars($memberHid1).'" />';?> <?php echo'<input type="hidden" name="memberHid" value="'.htmlspecialchars($memberHid).'" />';?> <p><input type="submit" name="Addmember"value="AddMember" /></p> </form> <?php "</td></tr>"; } echo "</table>"; } echo"<p><a href='memberlist.php'>List members</a></p>"; echo"<p><a href='logout.php'>Log out</a></p>"; } else { echo "<p> Connection timeout!</p>"; echo"<p><a href='login.php'>Log in</a></p></div>"; } ?> memberaddprocess code <?php ////////////////////////////////////// session_start(); require_once('sqlconnect.inc.php'); ///////////////////////////////////// $memberHid1 = $_POST['memberHid1']; //profilename of the friend whose corresponding button was clicked $new_session = $_POST['memberHid']; //profilename of the currently logged in user $conn = @mysqli_connect($host, $user, $pswd, $dbnm); if (!$conn) { echo "<p>Database connection failure</p>"; } else { @mysqli_select_db($conn, $dbnm) or die ("Database not available"); } $query = "SELECT member_id FROM team WHERE member_name = '$memberHid1'"; $queryResult = @mysqli_query($conn, $query) or die ("<p>Unable to execute query.</p>". "<p>Error code:" . mysqli_errno($conn) .":" . mysqli_error($conn)); $fetchArr = mysqli_fetch_row($queryResult); $memberHid3 = $fetchArr[0]; $memberHid = $_SESSION['membername'] = $new_session; $query2 = "SELECT member_id FROM member WHERE member_name = '$memberHid'"; $queryResult2 = @mysqli_query($conn,$query2) or die ("<p>Unable to execute query.</p>". "<p>Error code" . mysqli_errno($conn) .":" . mysqli_error($conn)); $fetchArr2 = mysqli_fetch_row($queryResult2); $memberHid4 = $fetchArr2[0]; $query3 = "INSERT INTO myteam VALUES($memberHid4, $memberHid3)"; $queryResult3 = @mysqli_query($conn,$query3) or die ("<p>Unable to execute query.</p>". "<p>Error code" . mysqli_errno($conn) .":" . mysqli_error($conn))."</p>"; echo "<p>$memberHid1"." "." Successfully added</p>"; $queryCount = "SELECT COUNT(*) FROM team"; $countResult = @mysqli_query($conn,$queryCount); $fetchCountArr = mysqli_fetch_row($countResult); for($n=0;$n<$fetchCountArr[0];$n++) { $pst = $n+1; $query4 = "SELECT member_id2 FROM myteam WHERE friend_id1 = '$pst'"; $countResult2 = @mysqli_query($conn,$query4); $countArr = mysqli_fetch_row($countResult2); $a=0; while($countArr) { $a++; $countArr = mysqli_fetch_row($countResult2); //echo "<p>$a</p>"; } $query4 = "UPDATE team SET num_of_members= '$a' WHERE member_id = '$pst'"; $countResult2 = @mysqli_query($conn,$query4); } $querySelect = "SELECT member_id2 FROM myteam WHERE member_id1 = '$memberHid4'"; $querySelectResult = @mysqli_query($conn, $querySelect); $fetchArr = mysqli_fetch_row($querySelectResult); while($fetchArr) { foreach($fetchArr as $value) { //echo $value; $querySelect2 = "SELECT member_name FROM friends where friend_id='$value'"; $querySelectResult2 = @mysqli_query($conn, $querySelectResult2); $fetchArr2 = mysqli_fetch_row($querySelectResult2); foreach($fetchArr2 as $value) { //echo $value; } } $fetchArr = mysqli_fetch_row($querySelectResult); } header("Location:memberadd.php"); echo('<a href="memberlist.php">Updated memberlist</a></p></div>'); //header('Location: friendadd.php'); ?> Quote Link to comment https://forums.phpfreaks.com/topic/283487-database-table-doesnt-exist-however-the-database-table-exist/ Share on other sites More sharing options...
mac_gyver Posted November 1, 2013 Share Posted November 1, 2013 is that the exact capitalization of the table name? any chance your actual table name has some white-space character(s) before or after it? Quote Link to comment https://forums.phpfreaks.com/topic/283487-database-table-doesnt-exist-however-the-database-table-exist/#findComment-1456443 Share on other sites More sharing options...
Tuscanbot Posted November 1, 2013 Author Share Posted November 1, 2013 @mac_gyver is there a way to show all the table name via php? as for the actual table it shouldnt have white space. As far I remember, ive created two tables, one is called 'team' and one is called 'myteam'. Quote Link to comment https://forums.phpfreaks.com/topic/283487-database-table-doesnt-exist-however-the-database-table-exist/#findComment-1456445 Share on other sites More sharing options...
Solution mac_gyver Posted November 1, 2013 Solution Share Posted November 1, 2013 As far I remember, ive created two tables, one is called 'team' and one is called 'myteam'. then why are you asking about a query and an error for the table member - Error code1146:Table '******_db.member' doesn't exist your query - $query2 = "SELECT member_id FROM member WHERE member_name = '$memberHid'" ; when you get error messages, you need to actually look at them and at the code/query that is producing them. Quote Link to comment https://forums.phpfreaks.com/topic/283487-database-table-doesnt-exist-however-the-database-table-exist/#findComment-1456446 Share on other sites More sharing options...
Tuscanbot Posted November 1, 2013 Author Share Posted November 1, 2013 Thanks Mac_Gyer, how could i not notice that , thanks once again Quote Link to comment https://forums.phpfreaks.com/topic/283487-database-table-doesnt-exist-however-the-database-table-exist/#findComment-1456448 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.