JJohnsenDK Posted November 20, 2006 Share Posted November 20, 2006 HeyWhy do i have to refesh the browser to view the text in the form? I cant see the error. Also when i hit the submit button the text again disapires, why? [code]<?phpfunction forside(){ include('../config_sit00045.php'); $hent = mysql_query("SELECT * FROM forside"); while ($vis = mysql_fetch_array($hent)){ $overskrift = $vis['side_overskrift']; $tekst = $vis['side_tekst']; }?><form method='POST'> Overskrift: <br /> <TEXTAREA rows="1" cols="40" name="side_overskrift"><?php echo $overskrift; ?></TEXTAREA> <br /> <br /> Tekst: <br /> <TEXTAREA rows="8" cols="75" name="side_tekst"><?php echo $tekst; ?></TEXTAREA> <br /> <br /> <input type='submit' value='Ændre'></form><?php $hent = mysql_query("SELECT * FROM forside"); $overskrift = $_POST['side_overskrift']; $tekst = $_POST['side_tekst']; $query = mysql_query("UPDATE `forside` SET `side_overskrift` = '".$overskrift."', `side_tekst` = '".$tekst."'");}?>[/code] Quote Link to comment Share on other sites More sharing options...
jwk811 Posted November 20, 2006 Share Posted November 20, 2006 did you asign the post variables to those variables you have to display the value? that might be the problem because i cant see that you did that Quote Link to comment Share on other sites More sharing options...
JJohnsenDK Posted November 21, 2006 Author Share Posted November 21, 2006 I dont understand what you mean. Can you give an example? Quote Link to comment Share on other sites More sharing options...
avo Posted November 21, 2006 Share Posted November 21, 2006 HiYour not using the function code you have created to do anything with does this need to be a function ?does it need to be there at all?[code]function forside(){ include('../config_sit00045.php'); $hent = mysql_query("SELECT * FROM forside"); while ($vis = mysql_fetch_array($hent)){ $overskrift = $vis['side_overskrift']; $tekst = $vis['side_tekst']; }[/code]you are pulling the same information as if you would with the function here but your not including the db_name ,db_pass ect ect [code] $hent = mysql_query("SELECT * FROM forside"); $overskrift = $_POST['side_overskrift']; $tekst = $_POST['side_tekst']; [/code]then for the update maybe you could do with something like [code]if (isset($_POST['submit'])){$query = mysql_query("UPDATE 'forside' SET 'side_overskrift' = '".$_POST['side_overskrift']."', `side_tekst` = '".$_POST['ide_tekst']."'");}[/code]does this file also include a mysql_connect () config_sit00045.phpif not you will also need to connect to the db with the username, password , database name , database address hope this point you in the right direction. Quote Link to comment Share on other sites More sharing options...
JJohnsenDK Posted November 21, 2006 Author Share Posted November 21, 2006 Well... Im using the function in anohter script page. You know the code i have posted is in functions.php and then the functions in functions.php gets called in main.php. So im using the function. I dont understand this:[quote]you are pulling the same information as if you would with the function here but your not including the db_name ,db_pass ect ect[/quote]what do you mean?config_00045.php is the mysql_connect, just have anohter name :P Quote Link to comment Share on other sites More sharing options...
JJohnsenDK Posted November 21, 2006 Author Share Posted November 21, 2006 anyone who can help me out? Quote Link to comment Share on other sites More sharing options...
taith Posted November 22, 2006 Share Posted November 22, 2006 is it just me? or is this just overkill?[code] while($vis = mysql_fetch_array($hent)){ $overskrift = $vis['side_overskrift']; $tekst = $vis['side_tekst']; }[/code]and why are you trying to take information from a database that was already passed from the form?[code]<?function forside(){ include('../config_sit00045.php'); $hent = mysql_query("SELECT * FROM forside limit 1"); $vis = mysql_fetch_array($hent); $overskrift = $vis['side_overskrift']; $tekst = $vis['side_tekst'];?><form method='POST'> Overskrift: <br /> <TEXTAREA rows="1" cols="40" name="side_overskrift"><?=$_POST[overskrift];?></TEXTAREA> <br /> <br />Tekst: <br /> <TEXTAREA rows="8" cols="75" name="side_tekst"><?=$_POST[tekst];?></TEXTAREA> <br /> <br /><input type='submit' value='Ændre'></form><? $hent = mysql_query("SELECT * FROM forside"); $overskrift = $_POST['side_overskrift']; $tekst = $_POST['side_tekst']; $query = mysql_query("UPDATE `forside` SET `side_overskrift` = '".$overskrift."', `side_tekst` = '".$tekst."'");}?>[/code]if i understand what your trying to do that is :-) 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.