xux Posted November 6, 2006 Share Posted November 6, 2006 Hi, I am trying to get a field updated from a web interface,but it have been reporting some error.below are my codesThe textarea where the new data should be entered[code]<p align="center"><strong><font color="#9303BB" size="5"><u>Investment Tip Manager</u></font></strong></p> <p> </p> <form id="form1" name="form1" method="post" action="InvestmentManager.php"> <p>Enter quote:</p> <p> <label> <textarea name="investment_tip" cols="40" rows="8" id="investment_tip"></textarea> </label> </p> <label><br /> <input name="AddBtn" type="submit" id="AddBtn" value="Submit" /> </label></form> [/code]The code that does the update[code]<?php $investment_tip = $HTTP_POST_VARS['investment_tip']; $investment_tip = trim($investment_tip); $investment_tip = addslashes($investment_tip); //check the fields for errors, if any if(!$investment_tip || empty($investment_tip)){ echo "<p style=\"color: #CC0000;\" align=\"center\"><b>Error: </b>You need to enter Investment Tips to be uploaded </p><p align=\"center\"> Click the BACK button in the browser to go back or click <a href=\"investment_tip_manager.php\">here</a> to start all over</p>"; exit; @$db = mysql_pconnect('localhost', '', ''); if(!$db){ echo "<p style=\"color: #CC0000;\" align=\"center\">Could not connect to the database. Please try again later</p><p align=\"center\"> Please refresh this page and if the problem persists, contact <a href=\"mailto:webmaster@sources.org\">webmaster</a>. Thank you<br /></p>"; exit; } mysql_select_db('DB')or die ('Unable to select database!'); $query = "UPDATE investment SET investment_tip=\"".$investment_tip."\"";$result = mysql_query($query) or die ('Error in query: $query. ' . mysql_error()); if(!$result){ echo "<p style=\"color: #CC0000;\" align=\"center\"><b>Error: </b>Could not update the investment tip database. </p><p align=\"center\"> Click the BACK button in the browser to go back or click <a href=\""investment_tip_manager.php\">here</a> to start all over.</p>"; exit; }else{echo "<p style=\"color: #CC0000;\" align=\"center\"><b>Done: </b>Investment Tip database have been updated. </p>"; exit; } ?> </div> [/code]I will appreciate your assistance.My Regards Quote Link to comment Share on other sites More sharing options...
AndyB Posted November 6, 2006 Share Posted November 6, 2006 If you have code that reports 'some errors', it would have been helpful to tell us what they were. Stripped of a huge number of tabs that made the code hard to read and understand, it looks as though you have a series of unclosed 'if' loops.Try this version and let us know what errors you note:[code]<?php$investment_tip = $_POST['investment_tip'];$investment_tip = trim($investment_tip);$investment_tip = addslashes($investment_tip); //check the fields for errors, if anyif(!$investment_tip || empty($investment_tip)){ echo "<p style=\"color: #CC0000;\" align=\"center\"><b>Error: </b>You need to enter Investment Tips to be uploaded </p><p align=\"center\"> Click the BACK button in the browser to go back or click <a href=\"investment_tip_manager.php\">here</a> to start all over</p>"; exit;}$db = mysql_pconnect('localhost', '', ''); // make sure you have the right un/pwif(!$db){ echo "<p style=\"color: #CC0000;\" align=\"center\">Could not connect to the database. Please try again later</p><p align=\"center\"> Please refresh this page and if the problem persists, contact <a href=\"mailto:webmaster@sources.org\">webmaster</a>. Thank you<br /></p>"; exit;}mysql_select_db('DB')or die ('Unable to select database!');$query = "UPDATE investment SET investment_tip=\"".$investment_tip."\"";$result = mysql_query($query) or die ('Error in query: $query. ' . mysql_error()); if(!$result){ echo "<p style=\"color:#CC0000;\" align=\"center\"><b>Error: </b>Could not update the investment tip database. </p><p align=\"center\"> Click the BACK button in the browser to go back or click <a href=\""investment_tip_manager.php">here</a> to start all over.</p>"; exit;} else { echo "<p style=\"color: #CC0000;\" align=\"center\"><b>Done:</b>Investment Tip database have been updated. </p>"; exit;}?>[/code] Quote Link to comment Share on other sites More sharing options...
xux Posted November 6, 2006 Author Share Posted November 6, 2006 Hi, Thanks for the effort,but it is giving me this error[code]Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/sme/public_html/InvestmentManager.php on line 33[/code]ThanksMy Regards Quote Link to comment Share on other sites More sharing options...
joshi_v Posted November 6, 2006 Share Posted November 6, 2006 Replace this code [code]if(!$result){ echo "<p style=\"color:#CC0000;\" align=\"center\"><b>Error: </b>Could not update the investment tip database. </p><p align=\"center\"> Click the BACK button in the browser to go back or click <a href=\""investment_tip_manager.php">here</a> to start all over.</p>"; exit;} [/code]with this code[code]if(!$result){ echo "<p style=\"color:#CC0000;\" align=\"center\"><b>Error: </b>Could not update the investment tip database. </p><p align=\"center\"> Click the BACK button in the browser to go back or click <a href=\" investment_tip_manager.php\">here</a> to start all over.</p>"; exit;}[/code] Quote Link to comment Share on other sites More sharing options...
xux Posted November 6, 2006 Author Share Posted November 6, 2006 Thanks, let me try that out Quote Link to comment Share on other sites More sharing options...
xux Posted November 6, 2006 Author Share Posted November 6, 2006 Thanks it is now working 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.