wakkiki Posted August 4, 2007 Share Posted August 4, 2007 Ok i know thers probably errors witht he code below, I've tried for hours literally add single quotes where some sites tell me to add them , taking them away caus they do nothing. I keep cycling through errors. Basically Im using a php user system from source forge and modifying it. I just want to test updating sql from a submit button. So say when button is clicked the new value either as a actual value or an addition like below can be passed to the database and then the value returned as a print or echo. if ocassionaly managed to get the value to update (i checked the sql database) but it doest work at showing the updated value and now its completely broke. Can anyone who understands what im trying to do either look over what ive got and correct or write a simple version of what I should be doing. Thanks. <?php //Do not allow the page to be called directly. if(basename($_SERVER['PHP_SELF']) == "index.inc.php") { header("Location: index.php"); exit; } //If the user is logged in, show this content. global $valid_user; if(session_is_registered("valid_user")) { ?> This is an example text replace of user system Current Land: <form> <form name="script" form action="index.php" method="post"> <b>Increase Landmass</b> <input type="submit" value="submit"> </form> <?php if($_POST["submit"]) { $connection = @mysql_connect("$db_host", "$db_user", "$db_pass") or die("Couldn't connect."); $db = @mysql_select_db($db_name, $connection) or die("Couldn't select database."); $sql = "UPDATE user SET landmass = landmass + 1 where username=$valid_user; $result = @mysql_query($sql, $connection); echo $result; } ?> <table align="center" cellpadding="4" cellspacing="0" width="95%"> <tr> <td> <?php include("./templates/$template/global.inc.php"); ?> </td> </tr> </table> <?php } else //If the user isn't logged in, show this content. { ?> <table align="center" cellpadding="4" cellspacing="0" width="95%"> <tr> <td> <p>Welcome to <b><?php echo $sitename ?></b>! You are welcome to <a href="register.php">register</a> and enjoy all of the benefits of being a member here.</p> <p>Thanks for stopping by!</p> <?php include("./templates/$template/global.inc.php"); ?> </td> </tr> </table> <?php } ?> Quote Link to comment https://forums.phpfreaks.com/topic/63321-php-form-and-update-sql/ Share on other sites More sharing options...
wakkiki Posted August 4, 2007 Author Share Posted August 4, 2007 Wow do people seriously not know? and I was told this was the place to come for info. Quote Link to comment https://forums.phpfreaks.com/topic/63321-php-form-and-update-sql/#findComment-315575 Share on other sites More sharing options...
dbo Posted August 4, 2007 Share Posted August 4, 2007 I didn't even look at your code... and won't now. Your second comment is uncalled for. This is a good place to come for info, but you also need to bear in mind that people are donating there time. This isn't a support service you pay for and are guarenteed 15 minute response time it's a free community forum. In the future show up with a different attitude and you just might get some help. Quote Link to comment https://forums.phpfreaks.com/topic/63321-php-form-and-update-sql/#findComment-315576 Share on other sites More sharing options...
wakkiki Posted August 4, 2007 Author Share Posted August 4, 2007 yet it took you 6 minutes to respond with a sarcastic comment and I posted several hours ago. My request was genuine. I waited to see if people didnt know If not then Ill try some other forum. Thank you. I dont have an attitutude. Quote Link to comment https://forums.phpfreaks.com/topic/63321-php-form-and-update-sql/#findComment-315584 Share on other sites More sharing options...
dbo Posted August 4, 2007 Share Posted August 4, 2007 I just visit the forum to help people when I'm bored. I was working my way down the list and had you not responded as you did I would have helped you. So yeah, feel free to visit another forum and goodluck with your issue. Quote Link to comment https://forums.phpfreaks.com/topic/63321-php-form-and-update-sql/#findComment-315586 Share on other sites More sharing options...
wakkiki Posted August 5, 2007 Author Share Posted August 5, 2007 BUMP Quote Link to comment https://forums.phpfreaks.com/topic/63321-php-form-and-update-sql/#findComment-315969 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.