Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

allowing / in an insert

Status
Not open for further replies.

pugs421

Technical User
Joined
Nov 25, 2002
Messages
114
Location
US
I need to allow a user to enter like 2 1/2 bathrooms but the / doesnt work. How is this done?
 
Insufficient data for a meaningful answer.

Define "allow a user to enter" as you are using it in this context.

Define "doesn't work" as you are using it in this context.

Want the best answers? Ask the best questions: TANSTAAFL!!
 
Sorry, i try to keep my questions short so people will answer. An admin will be enter in the number of bathrooms into a text field.The number of bathrooms could be 2 1/2 but it only gets redisplayed as 2 1. In other words everything after the / is not there after the user/admin enters it into the text field. How would I handle this?
 
Don't post short questions -- post minimally descriptive questions with apropos subject lines. Some members don't like to play 20 questions.


Either I can't reproduce your error, or I'm not understanding your question.

With the following HTML:

Code:
<html><body>
<form method=&quot;POST&quot; action=&quot;show_string.php&quot;>
	<input type=&quot;text&quot; name=&quot;string&quot;>
	<input type=&quot;submit&quot;>
</form>
</body></html>

If I enter the string &quot;1 1/2 baths&quot; and submit the form, then the following script:

Code:
<?php
print $_POST['string'];
?>

outputs:

1 1/2 baths



Want the best answers? Ask the best questions: TANSTAAFL!!
 
The problem with the / must be caused from the insertion or retrieval to the database. How can I allow the user to enter the / character and store it in the database and display it correctly. I apologize for my post not being descriptive enough. I made sence to me at the time.
 
It is best to assume that none of us but you know about the circumstances of your problem.



I still can't duplicate your error. When I input &quot;1 1/2 bath&quot; into the from from my earlier post and submit the form, this script:

Code:
<?php
mysql_connect ('localhost', 'test', 'test');
mysql_select_db ('test');
$query = &quot;INSERT INTO foo(word) VALUES ('&quot; . $_POST['string'] . &quot;')&quot;;
mysql_query ($query) or die (mysql_query());
$the_index = mysql_insert_id();

$query = &quot;SELECT word from foo WHERE pkID = &quot; . $the_index;
$result = mysql_query($query);

while ($the_word = mysql_fetch_assoc($result))
{
	print $the_word['word'];
	print '<br>';
}

?>

Outputs &quot;1 1/2 bath&quot;

Want the best answers? Ask the best questions: TANSTAAFL!!
 
Thats odd. Unfortunatley I'm at work so I cant check out my code but it appears to be the same circumstance as you just described. I appreciate your help. I'll have to post later.
 
I'm sorry for wasting your time on a stupid error.When I set up my database field for bathrooms I set the max length to 2 thinking there is no way someone had more bathrooms than 99. Then I realized that a possible value could be ex. 1 1/2 and forgot about the max value. I just assumed it was getting cut off somehow because of the / symbol. All better now.

signed,
Stupid
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top