Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Table does not exist message

Status
Not open for further replies.

omega1983

Programmer
Dec 21, 2004
32
US
I set up a table in a database called mafishin_Database1. I am using mysql server side and checked and verified that the table does exist. I set up a table called manage.php with the code listed below. It allows the user to put in an email address, choose suscribe or unsuscribe radio button, then choose the submit button. When I choose the submit button I get the following message: Table mafishin_Database1.suscribers does not exist. Puzzling since I verified that the table does exist. I checked the spelling of the table and the database. Any thoughts/suggestions

<?php
//set up a couple of functions
function doDB() {
global $conn;
//connect to server and select database; you may need it
$conn = mysql_connect("localhost", "mafishin_admin", "passway") or die(mysql_error());
mysql_select_db("mafishin_Database1",$conn) or die(mysql_error());
}

function emailChecker($email) {
global $conn, $check_result;
//check that email is not already in list
$check = "select id from subscribers where email = '$email'";
$check_result = mysql_query($check,$conn) or die(mysql_error());
}

//determine if they need to see the form or not
if ($_POST[op] != "ds") {
//they do, so create form block
$display_block = "
<form method=POST action=\"$_SERVER[PHP_SELF]\">

<p><strong>Your E-Mail Address:</strong><br>
<input type=text name=\"email\" size=40 maxlength=150>

<p><strong>Action:</strong><br>
<input type=radio name=\"action\" value=\"sub\" checked> subscribe
<input type=radio name=\"action\" value=\"unsub\"> unsubscribe

<input type=\"hidden\" name=\"op\" value=\"ds\">

<p><input type=submit name=\"submit\" value=\"Submit Form\"></p>
</form>";

} else if (($_POST[op] == "ds") && ($_POST[action] == "sub")) {
//trying to subscribe; validate email address
if ($_POST == "") {
header("Location: manage.php");
exit;
}

//connect to database
doDB();

//check that email is in list
emailChecker($_POST[email]);

//get number of results and do action
if (mysql_num_rows($check_result) < 1) {
//add record
$sql = "insert into subscribers values('', '$_POST[email]')";
$result = mysql_query($sql,$conn) or die(mysql_error());
$display_block = "<P>Thanks for signing up!</P>";
} else {
//print failure message
$display_block = "<P>You're already subscribed!</P>";
}
} else if (($_POST[op] == "ds") && ($_POST[action] == "unsub")) {
//trying to unsubscribe; validate email address
if ($_POST[email] == "") {
header("Location: manage.php");
exit;
}

//connect to database
doDB();

//check that email is in list
emailChecker($_POST[email]);

//get number of results and do action
if (mysql_num_rows($check_result) < 1) {
//print failure message
$display_block = "<P>Couldn't find your address!</P>
<P>No action was taken.</P>";
} else {
//unsubscribe the address
$id = mysql_result($check_result, 0, "id");
$sql = "delete from subscribers where id = '$id'";
$result = mysql_query($sql,$conn) or die(mysql_error());
$display_block = "<P>You're unsubscribed!</p>";
}
}
?>
<HTML>
<HEAD>
<TITLE>Subscribe/Unsubscribe</TITLE>
</HEAD>
<BODY>
<h1>Subscribe/Unsubscribe</h1>
<?php echo "$display_block"; ?>
</BODY>
</HTML>
 
Is the verified table name from your database the same, including capitalization, as the name you're using in your code? Depending on the filesystem on which you have MySQL installed and the table type you're using, MySQL's database and table names can be case-specific.


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top