nirjhor Posted January 25, 2012 Share Posted January 25, 2012 I am writing a code for a page which will get certain information from database into fields and update edited information. I can get information from database, but cannot update the edited information to database. Please, Can anyone help me ? <? session_start(); include("includes/connection.php"); include("includes/config.php"); $sqlsettings = "SELECT * from admin"; $resultsettings = mysql_query($sqlsettings); $rowsettings = @mysql_fetch_array($resultsettings); if ($_SESSION['MyAccount']=='') { $_SESSION['MyAccount'] = "MyAccount"; header('LOCATION: login.php'); exit(); } $msg=''; if($_POST['continue'] == "true") { $AddedDate = $_POST['AddedDate']; $sqlUpdate = "UPDATE buyer_career SET CareerTitle='".mysql_real_escape_string($_POST['CareerTitle'])."', CareerDescription='".mysql_real_escape_string($_POST['CareerDescription'])."', ExpiryDate='".mysql_real_escape_string($_POST['ExpiryDate'])."', where BuyerCareerID=".$_POST['BuyerCareerID']; $result=mysql_query($sqlUpdate); header("Location:buyers_career.php?msg=Buying Lead has been updated successfully"); exit(); } ?> <? //retreiving data from selling leads $sqlBuyingLead="select * from buyer,buyer_career where buyer.BuyerID=buyer_career.BuyerID and BuyerCareerID=".$_GET['BuyerCareerID']; $resultBuyingLead=mysql_query($sqlBuyingLead); $buying_row=@mysql_fetch_array($resultBuyingLead); ?> <form name="PostNewCareer" method="post" action="edit_buyer_career.php" enctype="multipart/form-data" onSubmit="return validate(this);"> <input type="text" name="CareerTitle" style="width: 400px" class="basicPoint" id="CareerTitle" value="<?=$buying_row['CareerTitle']?>" /> <input type="hidden" name="AddedDate" value="<?=$buying_row['AddedDate']?>"> <input type="text" name="CareerVacancies" style="width: 400px" class="basicPoint" id="CareerVacancies" value="<?=$buying_row['CareerVacancies']?>"/> <input type="hidden" name="continue" value="true"> <input type="hidden" name="BuyerCareerID" id="BuyerCareerID" value="<?=$_GET['BuyerCareerID']?>"/> <input type="submit" value="Update Buying Lead" name="submitButton" /> Quote Link to comment https://forums.phpfreaks.com/topic/255768-mysql-database-value-doesnt-update/ Share on other sites More sharing options...
scootstah Posted January 25, 2012 Share Posted January 25, 2012 Remove the comma between the last set and the where clause. ExpiryDate='".mysql_real_escape_string($_POST['ExpiryDate'])."', where BuyerCareerID=".$_POST['BuyerCareerID'] Quote Link to comment https://forums.phpfreaks.com/topic/255768-mysql-database-value-doesnt-update/#findComment-1311114 Share on other sites More sharing options...
nirjhor Posted January 25, 2012 Author Share Posted January 25, 2012 Thnx .. It is solved. I didn't noticed that part. I am a new comer in PHP & MySql. Hope to get more helps from you guys. Quote Link to comment https://forums.phpfreaks.com/topic/255768-mysql-database-value-doesnt-update/#findComment-1311120 Share on other sites More sharing options...
scootstah Posted January 25, 2012 Share Posted January 25, 2012 In the future, when queries appear to do nothing, use mysql_error() to print any query errors out. Quote Link to comment https://forums.phpfreaks.com/topic/255768-mysql-database-value-doesnt-update/#findComment-1311125 Share on other sites More sharing options...
nirjhor Posted January 25, 2012 Author Share Posted January 25, 2012 In the future, when queries appear to do nothing, use mysql_error() to print any query errors out. Thnx scootstah. I will remember that. Quote Link to comment https://forums.phpfreaks.com/topic/255768-mysql-database-value-doesnt-update/#findComment-1311127 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.