here's the problem .. i'm trying to have the user select a network, which accesses a table in my database, then from there there the user is given an option to delete that record.
it goes through three pages (see code below) to finally the 3rd page - where i get two errors ...
delete.html
______________
Select the NETWORK to DELETE the record from<br>
<b>REMEMBER THAT ONCE YOU PRESS "DELETE" THE ACTION CANNOT BE REVERSED! BE SMART.</b><br>
<form action="delete.php" method="post" name="coolThing">
<select name="network" >
<option value="ak">Alaska</option>
<option value="c">California</option>
<option value="h">Hawaii</option>
<option value="j">Japan</option>
<option value="k">Korea</option>
<option value="a">Australia</option>
<option value="f">France</option>
<option value="g">Germany</option>
<option value="u">Ukraine</option>
</select>
<input type="Submit" name="submit" value="Enter Network">
</form>
the first page works fine (basic html redirecting to a php page) ...
delete.php
-------------------
<?php
//create a var name for network to search by
$network=$HTTP_POST_VARS['network'];
$network=addslashes($network);
//connect to the database
$db = mysql_connect(###,###,###);
//error statement if database cannot be conencted to
if (!$db) { echo 'Error: Could not connect to the database. Please try again later.'; exit; }
//select the database that we are working withi
mysql_select_db("myDb",$db);
//display all the records in that table so the user can select which one to delete
$query = "SELECT * FROM $network";
//put the query into a result form and tell it which database to look in
$result = mysql_query($query,$db);
//this line is for troubleshooting - it prints out the query that you submitted to the screen
//print "<br>" . $query . "<br>";
//put data in a table for formatting reasons
echo "<p><b>Results for the *** $network *** network</b></p>";
echo "<table><font size=2>";
echo "<tr><td>***</td><td>***</td><td>***</td><td>***</td><td>***</td><td>***</td><td>***</td><td>***</td><td>***</td><td>***</td><td>***</td><td>***</td></font></tr>\n";
//loop through the table and print all of the information
while ($myrow = mysql_fetch_array($result)){
printf("<font size=2><tr><td>$myrow[0]</td><td>$myrow[1]\t</td><td>$myrow[2]</td><td>$myrow[3]</td><td>$myrow[4]</td><td>$myrow[5]</td><td>$myrow[6]</td><td>$myrow[7]</td><td>$myrow[8]</td><td>$myrow[9]</td><td>$myrow[10]</td><td>$myrow[11]</td><td>$myrow[12]</td><td><a href=\"%s?name=%s&delete=yes\"><form action=\"delete_confirm.php\" method=\"post\"<input type=\"submit\" value=\"Delete\"></form></a><br></td></tr></font>\n",$PHP_SELF, $myrow["0"], $myrow["1"], $myrow["2"], $myrow["3"], $myrow["4"], $myrow["5"], $myrow["6"], $myrow["7"], $myrow["8"],$myrow["9"], $myrow["10"],$myrow["11"]);
}
echo "</font></table>";
finally i send it to the last page...
delete_confirm.php
--------------
<?php
$query = "DELETE FROM $network WHERE name=$name";
$result = mysql_query($query,db);
echo "<p><b>Results for the *** $network *** network deleted successfully</b></p>";
echo "<table><font size=2>";
echo "<tr><td>***</td><td>***</td><td>***</td><td>***</td><td>Type</td><td>***</td><td>***</td><td>***</td><td>***</td><td>***</td><td>***</td><td>***</td></font></tr>\n";
//loop through the table and print all of the information
while ($myrow = mysql_fetch_array($result)) {
printf("<font size=2><tr><td>$myrow[0]</td><td>$myrow[1]\t</td><td>$myrow[2]</td><td>$myrow[3]</td><td>$myrow[4]</td><td>$myrow[5]</td><td>$myrow[6]</td><td>$myrow[7]</td><td>$myrow[8]</td><td>$myrow[9]</td><td>$myrow[10]</td><td>$myrow[11]</td><td>$myrow[12]</td><td><a href=\"%s?name=%s&delete=yes\">(DELETE)</a><br></td></tr></font>\n",$PHP_SELF, $myrow["0"], $myrow["1"], $myrow["2"], $myrow["3"], $myrow["4"], $myrow["5"], $myrow["6"], $myrow["7"], $myrow["8"],$myrow["9"], $myrow["10"],$myrow["11"]);
}
echo "</font></table>";
?>
when i do this i get the following errors...
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource
and
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource
(I've edited out the fields in here and stuff like that, but my first field is "name")
ANy help on fixing this error as well as combining all three pages into one (if it is possible) would be awesome!
Thank you so much in advance
it goes through three pages (see code below) to finally the 3rd page - where i get two errors ...
delete.html
______________
Select the NETWORK to DELETE the record from<br>
<b>REMEMBER THAT ONCE YOU PRESS "DELETE" THE ACTION CANNOT BE REVERSED! BE SMART.</b><br>
<form action="delete.php" method="post" name="coolThing">
<select name="network" >
<option value="ak">Alaska</option>
<option value="c">California</option>
<option value="h">Hawaii</option>
<option value="j">Japan</option>
<option value="k">Korea</option>
<option value="a">Australia</option>
<option value="f">France</option>
<option value="g">Germany</option>
<option value="u">Ukraine</option>
</select>
<input type="Submit" name="submit" value="Enter Network">
</form>
the first page works fine (basic html redirecting to a php page) ...
delete.php
-------------------
<?php
//create a var name for network to search by
$network=$HTTP_POST_VARS['network'];
$network=addslashes($network);
//connect to the database
$db = mysql_connect(###,###,###);
//error statement if database cannot be conencted to
if (!$db) { echo 'Error: Could not connect to the database. Please try again later.'; exit; }
//select the database that we are working withi
mysql_select_db("myDb",$db);
//display all the records in that table so the user can select which one to delete
$query = "SELECT * FROM $network";
//put the query into a result form and tell it which database to look in
$result = mysql_query($query,$db);
//this line is for troubleshooting - it prints out the query that you submitted to the screen
//print "<br>" . $query . "<br>";
//put data in a table for formatting reasons
echo "<p><b>Results for the *** $network *** network</b></p>";
echo "<table><font size=2>";
echo "<tr><td>***</td><td>***</td><td>***</td><td>***</td><td>***</td><td>***</td><td>***</td><td>***</td><td>***</td><td>***</td><td>***</td><td>***</td></font></tr>\n";
//loop through the table and print all of the information
while ($myrow = mysql_fetch_array($result)){
printf("<font size=2><tr><td>$myrow[0]</td><td>$myrow[1]\t</td><td>$myrow[2]</td><td>$myrow[3]</td><td>$myrow[4]</td><td>$myrow[5]</td><td>$myrow[6]</td><td>$myrow[7]</td><td>$myrow[8]</td><td>$myrow[9]</td><td>$myrow[10]</td><td>$myrow[11]</td><td>$myrow[12]</td><td><a href=\"%s?name=%s&delete=yes\"><form action=\"delete_confirm.php\" method=\"post\"<input type=\"submit\" value=\"Delete\"></form></a><br></td></tr></font>\n",$PHP_SELF, $myrow["0"], $myrow["1"], $myrow["2"], $myrow["3"], $myrow["4"], $myrow["5"], $myrow["6"], $myrow["7"], $myrow["8"],$myrow["9"], $myrow["10"],$myrow["11"]);
}
echo "</font></table>";
finally i send it to the last page...
delete_confirm.php
--------------
<?php
$query = "DELETE FROM $network WHERE name=$name";
$result = mysql_query($query,db);
echo "<p><b>Results for the *** $network *** network deleted successfully</b></p>";
echo "<table><font size=2>";
echo "<tr><td>***</td><td>***</td><td>***</td><td>***</td><td>Type</td><td>***</td><td>***</td><td>***</td><td>***</td><td>***</td><td>***</td><td>***</td></font></tr>\n";
//loop through the table and print all of the information
while ($myrow = mysql_fetch_array($result)) {
printf("<font size=2><tr><td>$myrow[0]</td><td>$myrow[1]\t</td><td>$myrow[2]</td><td>$myrow[3]</td><td>$myrow[4]</td><td>$myrow[5]</td><td>$myrow[6]</td><td>$myrow[7]</td><td>$myrow[8]</td><td>$myrow[9]</td><td>$myrow[10]</td><td>$myrow[11]</td><td>$myrow[12]</td><td><a href=\"%s?name=%s&delete=yes\">(DELETE)</a><br></td></tr></font>\n",$PHP_SELF, $myrow["0"], $myrow["1"], $myrow["2"], $myrow["3"], $myrow["4"], $myrow["5"], $myrow["6"], $myrow["7"], $myrow["8"],$myrow["9"], $myrow["10"],$myrow["11"]);
}
echo "</font></table>";
?>
when i do this i get the following errors...
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource
and
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource
(I've edited out the fields in here and stuff like that, but my first field is "name")
ANy help on fixing this error as well as combining all three pages into one (if it is possible) would be awesome!
Thank you so much in advance