Update MySQL DB from a form
Moderator: General Moderators
Re: Update MySQL DB from a form
Hmmm,
It still doesn't work and if I take out the header page it just goes blank and says Done at the bottom in ie
It still doesn't work and if I take out the header page it just goes blank and says Done at the bottom in ie
Re: Update MySQL DB from a form
add one more line to it to see what the errors are
$myrow = $_POST['L_ID'];
mysql_query("UPDATE login SET level = 2 WHERE L_ID = $myrow ");
echo mysql_error();
$myrow = $_POST['L_ID'];
mysql_query("UPDATE login SET level = 2 WHERE L_ID = $myrow ");
echo mysql_error();
Re: Update MySQL DB from a form
Unknown column 'level' in 'field list'
Re: Update MySQL DB from a form
are you sure there is a level field in your database? as the error indicates that you don't have level field in your database..Check you database field again to see what the field name for level is
Re: Update MySQL DB from a form
forget that last error, it should be "access" and not "level"
BUT, the page is still blank
$myrow = $_POST['L_ID'];
mysql_query("UPDATE login SET access = 2 WHERE L_ID = $myrow ");
echo mysql_error();
BUT, the page is still blank
$myrow = $_POST['L_ID'];
mysql_query("UPDATE login SET access = 2 WHERE L_ID = $myrow ");
echo mysql_error();
Re: Update MySQL DB from a form
man, thats stranged..lets try this .
$myrow = $_POST['L_ID'];
mysql_query("UPDATE login SET access = '2' WHERE L_ID = '".$myrow."'");
echo mysql_error();
$myrow = $_POST['L_ID'];
mysql_query("UPDATE login SET access = '2' WHERE L_ID = '".$myrow."'");
echo mysql_error();
Re: Update MySQL DB from a form
HOLD THE PHONE,
I have found one thing out.
When I uploaded I was in the DB. I refreshed the DB and nothing happened. If I was out of the DB and used the code you provided and then went back into the DB, it had worked.
Why is that? I have made changes before and then refreshed and it normally works???
I have found one thing out.
When I uploaded I was in the DB. I refreshed the DB and nothing happened. If I was out of the DB and used the code you provided and then went back into the DB, it had worked.
Why is that? I have made changes before and then refreshed and it normally works???
Re: Update MySQL DB from a form
I think its because of the browser cache..but is it working now ?
Re: Update MySQL DB from a form
Sure is 
Many thanks for your support mate, it's appreciated.
I am an ASP guy and this php stuff is very different lol.
Cheers again.
Many thanks for your support mate, it's appreciated.
I am an ASP guy and this php stuff is very different lol.
Cheers again.
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Re: Update MySQL DB from a form
Is L_ID an integer type? Is access? If they are leave off the quotes around them. Also, make sure you check for a value and type in the posted item so you can save yourself a trip to the database if it is not what you expected.
Code: Select all
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if (!empty($_POST['L_ID']) && is_numeric($_POST['L_ID'])) {
// If you are only using this var once, don't assign it, just use the post var
$myrow = $_POST['L_ID'];
if (!mysql_query("UPDATE login SET access = 2 WHERE L_ID = $myrow")) {
die('There was an error: ' . mysql_error()); // Do NOT use this in production
}
}
}
?>