now try it, I had an error in the code
Printable View
now try it, I had an error in the code
umm you didnt post anything.
i used a mysql_error and this is what showed with alter table:
i use mysql5.Quote:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SET `approved` = '1' WHERE `ID` = '100000'' at line 1
so i changed it back to update and there was no error. but it still didnt change.
Good good, very useful information. and I was wrong about Alter Table.. I use that for a totally different thing. :) I see the problem is that $id, ($_POST['approved']), is set to 100000. I'll take a wild guess you have 6 IDs, and your script is trying to get the 100,000'th ID, while there is only 6. Somewhere in your submitting code that has the field 'approved', needs to be changed. post that code?
you think the $id is 100000 right?PHP Code:<?php
if (isset($_POST['approve'])) {
$id = $_POST['approve'];
mysql_connect("localhost", "ashin951_keydb", "keydb") or die(mysql_error());
mysql_select_db("ashin951_keydb") or die(mysql_error());
$ticked = $_POST['approve'];
foreach($ticked as &$id) {
mysql_query("UPDATE `service` SET `approved` = '1' WHERE `ID` = '{$id}'");
}
unset($id);
echo "Successfully Approved.";
} else {
echo "Access Denied.";
}
?>
<title>Approval</title>
ill echo it.
i added
underneath $id and it just says array. so i believe that the script before this is not sending the correct information.PHP Code:echo $id;
die();
it's supposed to be echo("$id"); and you don't need a die message for an echo..
And what's with the {} brackets around {$id} inside the sql statement?
And believe me, $id is coming out as 100000 and that's a fact if the code you give me is true. I'm getting the picture to what the problem is... but I need more access for testing and working out the problem until I know it works. The most I can do is look for little mistakes that might be the problem.. And that's not going to help in this case. I need to see the big picture to really help you.
EDIT: I need to see the page the sends $_POST['approve']
oh i see. i made my own mistake. for my query on the first script, i selected the wrong table. you were right it was 100000. =]
I went through this page and tested it. I decided to put a select option menu on the bottum instead of check boxes because of technical reasons. well.. just see if this works, and ask questions later.
As for the landing page.. Just see if this works now.PHP Code:<?php
session_start();
if(isset($_SESSION['verify'])) {
echo "<h1>Approval Section</h1><br>";
mysql_connect("localhost", "ashin951_keydb", "___") or die(mysql_error());
mysql_select_db("ashin951_keydb") or die(mysql_error());
//User Approval Script
$query = mysql_query("SELECT service.id, service.action, service.hours, community.name FROM service, community WHERE community.approved = 0 AND community.id = service.id");
//$result2 = mysql_query("SELECT * FROM service WHERE approved='0'") or die(mysql_error());
//$result3 = mysql_query("SELECT * FROM community") or die(mysql_error());
echo "<table border='1'>";
echo "<tr> <th>Name</th> <th>Action</th> <th>Hours</th> <th>Approve</th> </tr>";
while($row = mysql_fetch_array($query)) {
// Print out the contents of each row into a table
echo "<tr><td>";
echo $row['name'];
echo "</td><td>";
echo $row['action'];
echo "</td>";
echo "<td>";
echo $row['hours'];
echo "</td><td>";
}
print "<form action=\"approve.php\" method=\"post\">Approve: <select name=\"approve\">";
while($row = mysql_fetch_array($query)) {
$id = $row['id'];
$name= $row['name'];
echo "<option value=\"$id\">$name</option>";
echo "</td></tr>";
}
print "</select>";
echo "</table>";
echo "<input type=\"submit\" name=\"Approve\" value=\"Approve\"></form>";
} else {
echo "Access Denied.";
}
?>
what kind of technical reasons. i said it worked fine. thanks for your help. =]