scarlson Posted December 7, 2007 Share Posted December 7, 2007 What is wrong with my query? mysql_query("UPDATE login SET lName = '$lName', fName = '$fName', address = '$address', zip = '$zip', phone = '$phone', start_date = '$start_date')"; Thanks, Scott Quote Link to comment https://forums.phpfreaks.com/topic/80564-solved-error-when-updating-database/ Share on other sites More sharing options...
pocobueno1388 Posted December 7, 2007 Share Posted December 7, 2007 Your quotes are messed up at the end mysql_query("UPDATE login SET lName = '$lName', fName = '$fName', address = '$address', zip = '$zip', phone = '$phone', start_date = '$start_date'")or die(mysql_error()); You do know you don't have a WHERE clause, right? That will update EVERY record in your DB. Quote Link to comment https://forums.phpfreaks.com/topic/80564-solved-error-when-updating-database/#findComment-408532 Share on other sites More sharing options...
scarlson Posted December 7, 2007 Author Share Posted December 7, 2007 That took care of the error but my query is not updating my database. I am also not getting any errors either. What might be wrong? if(isset($_SESSION['myusername'])){ include "dbconnect.php"; if($_POST['submit']) { $username = $_SESSION['myusername']; $logid_query = mysql_query("SELECT * FROM login WHERE username='$username'"); $logid_array = mysql_fetch_array($logid_query); $logid = $logid_array['id']; $fName = $_POST['fName']; $lName = $_POST['lName']; $address = $_POST['address']; $zip = $_POST['zip']; $phone = $_POST['phone']; $start_date = $_POST['start_date']; $tod_girls = $_POST['tod_girl_clothes']; $tod_boy = $_POST['tod_boy_clothes']; $kid_girl = $_POST['kid_girl_clothes']; $kid_boy = $_POST['kid_boy_clothes']; $women = $_POST['women_clothes']; $men = $_POST['men_clothes']; $furniture = $_POST['furniture']; $games = $_POST['games']; $sporting_goods = $_POST['sporting_goods']; $sports_mem = $_POST['sports_mem']; $cookware = $_POST['cookware']; $tools = $_POST['tools']; $hunting_fishing = $_POST['hunting_fishing']; $exercise = $_POST['exercise_equip']; $jewlery = $_POST['jewlery']; $arts_crafts = $_POST['arts_crafts']; $pictures = $_POST['pictures']; $paintings = $_POST['paintings']; $rugs = $_POST['rugs']; $electronics = $_POST['electronics']; $house_app = $_POST['house_appliances']; $books = $_POST['books']; $antiques = $_POST['antiques']; $auto = $_POST['auto']; $seasonal = $_POST['seasonal']; $computers = $_POST['computers']; $toys = $_POST['toys']; $baby_items = $_POST['baby_items']; $lawn_equip = $_POST['lawn_equip']; $machinery = $_POST['machinery']; $media = $_POST['media']; $pets = $_POST['pets']; $misc = $_POST['misc']; mysql_query("UPDATE seller SET lName = '$lName', fName = '$fName', address = '$address', zip = '$zip', phone = '$phone', start_date = '$start_date' WHERE login_id = '$logid' "); } } Quote Link to comment https://forums.phpfreaks.com/topic/80564-solved-error-when-updating-database/#findComment-408595 Share on other sites More sharing options...
revraz Posted December 7, 2007 Share Posted December 7, 2007 Add the error checking after your mysql query or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/80564-solved-error-when-updating-database/#findComment-408601 Share on other sites More sharing options...
scarlson Posted December 7, 2007 Author Share Posted December 7, 2007 Thanks, found the error and fixed it and now it works. I need to get in the habit of using the or die statement. Quote Link to comment https://forums.phpfreaks.com/topic/80564-solved-error-when-updating-database/#findComment-408606 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.