basement Posted June 3, 2008 Share Posted June 3, 2008 the database connects properly so it isn't that. $connect = @mysql_connect('localhost',"******_" . $_SESSION['user'],$_SESSION['password']); if($connect == true){ @mysql_select_db($database, $connect); if(isset($_POST['Edit'])){ $description1=$_POST["description1"]; echo($description1); $query1 = "UPDATE Description SET description = $description1 WHERE id = 1"; <------------ if(mysql_query($query1)) <------------ echo("<h1>Company description has been updated.</h1>"); else echo("<p>Failed to update company description</p><br />"); ---------------------------------------------------------------------------------------- i'm sure the issue is one of the two lines that the arrows are pointing at. that page always says that it failed to update the company description and every time i reload it the changes haven't been saved. so the mysql_query isn't doing what i'm thinking it should. but i've probably made a mistake somewhere. and this line $result = @mysql_query("SELECT description FROM Description WHERE id=1") pulls description from the table correctly and consistently. Quote Link to comment Share on other sites More sharing options...
basement Posted June 3, 2008 Author Share Posted June 3, 2008 Further information. I added the or die(mysql_error()) line and it produced this 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 '******* is a publicly traded (***: ****) Canadian exploration-stage mining comp' at line 1 interesting the error is missing the first word of the textarea box. not sure why that is but it could be the issue. I really hope someone can help me with this. I'm trying to add data via another form and that one isn't working either. Using version 5.0.45 Quote Link to comment Share on other sites More sharing options...
luca200 Posted June 3, 2008 Share Posted June 3, 2008 Guess you should use quotes around your column values ;-) UPDATE Description SET description = '$description1' WHERE id = 1 Best again if you apply mysql_real_escape() to $description1 before submitting it to the database. Some little unrequested tips: - never use @ in front of db instructions - ALWAYS use "or die(mysql_error())" after EVERY db instruction - always escape data as above before giving it to the db if it comes from user Quote Link to comment Share on other sites More sharing options...
basement Posted June 3, 2008 Author Share Posted June 3, 2008 if(isset($_POST['Edit'])){ $description1=mysql_real_escape_string($_POST["description1"]); $query1 = "UPDATE Description SET description = '$description1' WHERE id = 1"; $result = mysql_query($query1) or die(mysql_error()); if($result) echo("<h1>Company description has been updated.</h1>"); else echo("<p>Failed to update company description.</p><br />"); working now. thank you very very much. wish you were on at 12am EST last night though! *rush rush rush* Quote Link to comment Share on other sites More sharing options...
basement Posted June 3, 2008 Author Share Posted June 3, 2008 nm Quote Link to comment Share on other sites More sharing options...
mushroom Posted June 3, 2008 Share Posted June 3, 2008 I do not see any "{}" with your if ,else statements if (....) { code ; } else { code ; } Quote Link to comment Share on other sites More sharing options...
basement Posted June 3, 2008 Author Share Posted June 3, 2008 don't need them if it's only one line. make the code look cleaner. Quote Link to comment 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.