Hi guys.
Having a mysterious problem here...
See that MySQL query? Apparantly something is wrong with that. I have google'd for the past week or so looking at how everybody else on the internet removes entries from databases, and its the same as how i'm doing it (with variations, of course - most of which i've tried).Code:$con = mysql_connect("localhost","username","password"); //connect to the mysql service if (!$con) //if there is no connection; { die('Could not connect: ' . mysql_error()); //provide error } mysql_select_db("radio", $con); //select which database we want to use $rem = $_POST['remuser']; if ($rem=="") { echo "Please select a user to remove. <a href='admin.php?sel=destroy'>Try again</a>"; } else { mysql_query("DELETE FROM 'accounts' WHERE username='$rem'"); //delete row from database echo "Removed " . $rem; }
Echoing the contents of $rem after the mysql query returns a user i have selected on a previous form to remove (drop down form, code below), which means, AFAIK, the form is working as it should.
Does anybody have any ideas as to why rows wont be deleted?Code:$blank = ""; $con = mysql_connect("localhost","username","password"); //connect to the mysql service if (!$con) //if there is no connection; { die('Could not connect: ' . mysql_error()); //provide error } mysql_select_db("radio", $con); //select which database we want to use $query="SELECT username FROM accounts"; /* You can add order by clause to the sql statement if the names are to be displayed in alphabetical order */ $result = mysql_query ($query); echo "Select a user to remove:<br> <form name='remuser' action='admin-destroy.php' method='post'> <select name='remuser'>Remove User</option>"; // printing the list box select command while($nt=mysql_fetch_array($result)){//Array or records stored in $nt if ($nt[username]=="radmin") { echo "<option value=$blank></option>"; } else { echo "<option value=$nt[username]>$nt[username]</option>"; } /* Option values are added by looping through the array */ } echo "</select> <input type='submit' value='Remove'/>";// Closing of list box }
php 5.2.5
mysql 5.0.51




Reply With Quote