Jump to content

Textbox Value

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
6 replies to this topic

#1
Bioshox

Bioshox

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 207 posts
Hey!

Id like to get the value of this textbox from a row in a MySQL database, iv tried with this code:

	while($row = mysql_fetch_assoc($res)) {
	$row['body'] = str_replace("<br>", "\n", $row['body']);  

		echo '<h3>Previous Name: <br>' . htmlspecialchars(stripslashes(($row['name']))) . '</h3>';

	}
	else:
		echo '<p>Oh Dear, This Is Embarrassing, It seems we cant find what your looking for!</p>';
		

		
	endif;
	
	
	}
	
//Ends Our Class



//Displays the posts


			get_content();
?>
<p>

<form action='updatename.php' method='post'>
<input type='text' name='content' size='63.5' value='<?php echo $row['name']; ?>'" /><br>
<br>
<input type='submit' name='submit' value='Edit Name' />
</p>


Any idea how I can get this working, its tearing my hair out!

#2
Orjan

Orjan

    Writes binary right handed and hex left handed

  • Moderators
  • 3,299 posts
why are you struggling with htmlspecialchars(stripslashes(($row['name']))) ??????

if you have done an mysql_real_escape_string() when you saved it into the database, you don't need the stripslashes on the way out. If you are afraid that they were adding html code, you should have done your specialchars on the way in, and don't need to do it again on the way out, as it would destroy the & in front of for example ö with &ouml;
__________________________________________
I study Information Systems at Karlstad University when I'm not on CodeCall

#3
Bioshox

Bioshox

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 207 posts

Orjan said:

why are you struggling with htmlspecialchars(stripslashes(($row['name']))) ??????

if you have done an mysql_real_escape_string() when you saved it into the database, you don't need the stripslashes on the way out. If you are afraid that they were adding html code, you should have done your specialchars on the way in, and don't need to do it again on the way out, as it would destroy the & in front of for example ö with &ouml;

THat's not the bit of the code im stuck at

I want to return the data stored in teh SQL table into the Text Box

The code I need to fix is this

<form action='updatename.php' method='post'>

<input type='text' name='content' size='63.5' value='<?php echo $row['name']; ?>'" /><br>

<br>

<input type='submit' name='submit' value='Edit Name' />

</p>


#4
Guest_Jaan_*

Guest_Jaan_*
  • Guests
Um.. try to print that value to somewhere else.. then you can see if it works, but if it don't work then there's something wrong with your SQL part..

can you show us the content of $res ?

#5
brokenbylaw

brokenbylaw

    Learning Programmer

  • Members
  • PipPipPip
  • 62 posts
as said above more info would rock.

#6
Bioshox

Bioshox

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 207 posts
Yeah, the information alreday echo's as I have it saying Previous: and whatever was in the row, as I cant get it working inside the text box D:

#7
brokenbylaw

brokenbylaw

    Learning Programmer

  • Members
  • PipPipPip
  • 62 posts
<input type='text' name='content' size='63.5' value='<?php echo $row['name']; ?>'" /><br>

look at it

'"

try

<input type='text' name='content' size='63.5' value="<?php echo $row['name']; ?>" /><br>