Cory94bailly Posted May 28, 2008 Share Posted May 28, 2008 My code: <?php ob_start(); require 'config.php'; // Make a MySQL Connection mysql_connect($path, $username, $password) or die(mysql_error()); mysql_select_db($database) or die(mysql_error()); //Starts if you click the submit button. if(isset($_POST['submit'])) { //Set the variable! //Update it! $query = "UPDATE notepad SET notepad='$updated'"; mysql_query($query) or die(mysql_error()); echo "<meta http-equiv='refresh' content='1;url=index.php'>"; echo "variables"; } else { //Error message. die('Error!!!!!!!!!'); } list($notepad) = mysql_fetch_row($result); //The form. ?> <form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post"> <p>Text:<br> <textarea rows="10" cols="50" name="news"><?php echo $notepad ?></textarea> </p> <input type="submit" name="submit" value="Submit"> </form> <?php //End it!!! ob_end_flush(); ?> Now all I am getting is "Error!!!!!!!!!" Any help? (Btw, I know I did it wrong somehow =/) Link to comment https://forums.phpfreaks.com/topic/107543-solved-admin-notepad/ Share on other sites More sharing options...
Cory94bailly Posted May 28, 2008 Author Share Posted May 28, 2008 Just noticed.. I didn't define 2 or 3 variables. New code: <?php ob_start(); require 'config.php'; // Make a MySQL Connection mysql_connect($path, $username, $password) or die(mysql_error()); mysql_select_db($database) or die(mysql_error()); //Starts if you click the submit button. if(isset($_POST['submit'])) { //Set the variable! //Update it! $query = "UPDATE notepad SET notepad='$updated'"; $updated = $_POST['updated']; mysql_query($query) or die(mysql_error()); echo "<meta http-equiv='refresh' content='1;url=index.php'>"; } else { //Error message. die('Error!!!!!!!!!'); } $query = "SELECT notepad FROM notepad"; list($notepad) = mysql_fetch_row($result); //The form. ?> <form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post"> <p>Text:<br> <textarea rows="10" cols="50" name="updated"><?php echo $notepad ?></textarea> </p> <input type="submit" name="submit" value="Submit"> </form> <?php //End it!!! ob_end_flush(); ?> Still get "Error!". Link to comment https://forums.phpfreaks.com/topic/107543-solved-admin-notepad/#findComment-551250 Share on other sites More sharing options...
peranha Posted May 28, 2008 Share Posted May 28, 2008 if(isset($_POST['submit'])) Try if(isset($_POST['updated'])) Link to comment https://forums.phpfreaks.com/topic/107543-solved-admin-notepad/#findComment-551252 Share on other sites More sharing options...
Cory94bailly Posted May 28, 2008 Author Share Posted May 28, 2008 if(isset($_POST['submit'])) Try if(isset($_POST['updated'])) Same error.. Btw, it should be submit so the script starts when the Submit button is hit. Link to comment https://forums.phpfreaks.com/topic/107543-solved-admin-notepad/#findComment-551254 Share on other sites More sharing options...
peranha Posted May 28, 2008 Share Posted May 28, 2008 That will only run the script is the button is hit. Link to comment https://forums.phpfreaks.com/topic/107543-solved-admin-notepad/#findComment-551255 Share on other sites More sharing options...
Cory94bailly Posted May 28, 2008 Author Share Posted May 28, 2008 That will only run the script is the button is hit. Yes..... I want it to update if they click submit, not update nothing............................................ Link to comment https://forums.phpfreaks.com/topic/107543-solved-admin-notepad/#findComment-551256 Share on other sites More sharing options...
peranha Posted May 28, 2008 Share Posted May 28, 2008 <form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post"> should be <form action="<?php $_SERVER['PHP_SELF']; ?>" method="post"> Link to comment https://forums.phpfreaks.com/topic/107543-solved-admin-notepad/#findComment-551257 Share on other sites More sharing options...
Cory94bailly Posted May 28, 2008 Author Share Posted May 28, 2008 Please, stop posting in this topic.. echoing it works too. Anyone else? Besides, that wouldn't cause the error. Link to comment https://forums.phpfreaks.com/topic/107543-solved-admin-notepad/#findComment-551258 Share on other sites More sharing options...
Cory94bailly Posted May 28, 2008 Author Share Posted May 28, 2008 Ok, I got it to atleast show the box now.. <?php ob_start(); require 'config.php'; // Make a MySQL Connection mysql_connect($path, $username, $password) or die(mysql_error()); mysql_select_db($database) or die(mysql_error()); //Starts if you click the submit button. if(isset($_POST['submit'])) { //Set the variable! //Update it! $query = "UPDATE notepad SET notepad='$updated'"; $updated = $_POST['updated']; mysql_query($query) or die(mysql_error()); echo "<meta http-equiv='refresh' content='1;url=index.php'>"; } $query = "SELECT notepad FROM notepad"; $result = mysql_query($query); list($notepad) = mysql_fetch_row($result); //The form. ?> <form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post"> <textarea rows="10" cols="50" name="updated"><?php echo $notepad ?></textarea> <input type="submit" name="submit" value="Submit"> </form> <?php //End it!!! ob_end_flush(); ?> But it's not showing the text if I submit it. Link to comment https://forums.phpfreaks.com/topic/107543-solved-admin-notepad/#findComment-551259 Share on other sites More sharing options...
peranha Posted May 28, 2008 Share Posted May 28, 2008 if you look at the error, you are missing the ; at the end. I just use a shorter version. If you dont want to listen, maybee you shouldnt be posting problems. Link to comment https://forums.phpfreaks.com/topic/107543-solved-admin-notepad/#findComment-551260 Share on other sites More sharing options...
Cory94bailly Posted May 28, 2008 Author Share Posted May 28, 2008 if you look at the error, you are missing the ; at the end. I just use a shorter version. If you dont want to listen, maybee you shouldnt be posting problems. Whatever. Anyone....???????? Link to comment https://forums.phpfreaks.com/topic/107543-solved-admin-notepad/#findComment-551262 Share on other sites More sharing options...
peranha Posted May 28, 2008 Share Posted May 28, 2008 <?php echo $_SERVER['PHP_SELF'] ?> <?php echo $notepad ?> you are missing the ; at the end of each of these. That is your problem. Link to comment https://forums.phpfreaks.com/topic/107543-solved-admin-notepad/#findComment-551263 Share on other sites More sharing options...
Cory94bailly Posted May 28, 2008 Author Share Posted May 28, 2008 <?php echo $_SERVER['PHP_SELF'] ?> <?php echo $notepad ?> you are missing the ; at the end of each of these. That is your problem. Again, no it wasn't.. Heh, still showing a blank box... I put text in it, submit, and it stays blank.. Link to comment https://forums.phpfreaks.com/topic/107543-solved-admin-notepad/#findComment-551268 Share on other sites More sharing options...
dezkit Posted May 28, 2008 Share Posted May 28, 2008 <?php echo $_SERVER['PHP_SELF']; ?> <?php echo $notepad; ?> Link to comment https://forums.phpfreaks.com/topic/107543-solved-admin-notepad/#findComment-551270 Share on other sites More sharing options...
Cory94bailly Posted May 28, 2008 Author Share Posted May 28, 2008 <?php echo $_SERVER['PHP_SELF']; ?> <?php echo $notepad; ?> Ok god! lol. It's just not inserting the data. Link to comment https://forums.phpfreaks.com/topic/107543-solved-admin-notepad/#findComment-551272 Share on other sites More sharing options...
DarkWater Posted May 28, 2008 Share Posted May 28, 2008 The original problem was that you had the die() and else clause attached to the if (isset($_POST)) thing. So therefore, it would immediately jump to that. Link to comment https://forums.phpfreaks.com/topic/107543-solved-admin-notepad/#findComment-551275 Share on other sites More sharing options...
peranha Posted May 28, 2008 Share Posted May 28, 2008 $updated = $_POST['updated']; That line needs to be before this line $query = "UPDATE notepad SET notepad='$updated'"; You need to assign the variable before you can use it. $updated = $_POST['updated']; $query = "UPDATE notepad SET notepad='$updated'"; Link to comment https://forums.phpfreaks.com/topic/107543-solved-admin-notepad/#findComment-551276 Share on other sites More sharing options...
Prismatic Posted May 28, 2008 Share Posted May 28, 2008 Sorry ignore this. Link to comment https://forums.phpfreaks.com/topic/107543-solved-admin-notepad/#findComment-551278 Share on other sites More sharing options...
Cory94bailly Posted May 28, 2008 Author Share Posted May 28, 2008 Well I got it to work.. <?php ob_start(); require 'config.php'; // Make a MySQL Connection mysql_connect($path, $username, $password) or die(mysql_error()); mysql_select_db($database) or die(mysql_error()); //Starts if you click the submit button. if(isset($_POST['submit'])) { //Set the variables! //Update it! $updated = $_POST['updated']; $query = "UPDATE notepad SET text='$updated'"; mysql_query($query) or die(mysql_error()); echo "<meta http-equiv='refresh' content='1'>"; } $query = "SELECT text FROM notepad"; $result = mysql_query($query); list($notepad) = mysql_fetch_row($result); //The form. ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <textarea rows="10" cols="50" name="updated"><?php echo $notepad; ?></textarea> <input type="submit" name="submit" value="Submit"> </form> <?php //End it!!! ob_end_flush(); ?> Link to comment https://forums.phpfreaks.com/topic/107543-solved-admin-notepad/#findComment-551280 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.