Sending a string with spaces from a from options value
Moderator: General Moderators
- cookie_monster
- Forum Newbie
- Posts: 5
- Joined: Sat Apr 12, 2003 8:41 am
- Location: Australia
Sending a string with spaces from a from options value
Is there a secret involved which will allows the whole string including spaces to be sent from a options value from within a form?
I have drop down options which contain file names and some of these file names have spaces in them. When they are selected in the drop down list they are added to a mysql database but only the first word before the first space gets added.
Could anyone help me please.
I have drop down options which contain file names and some of these file names have spaces in them. When they are selected in the drop down list they are added to a mysql database but only the first word before the first space gets added.
Could anyone help me please.
- scorphus
- Forum Regular
- Posts: 589
- Joined: Fri May 09, 2003 11:53 pm
- Location: Belo Horizonte, Brazil
- Contact:
Please post the code that gets info from the form. Also post the way you are querying the DB, the query itself. Also mention which method you are using POST or GET and, if you can, do a print_r($_POST) or print_r($_GET). Then I think you will get helped faster.
Best regards,
Sco.
Best regards,
Sco.
Last edited by scorphus on Sun Oct 26, 2003 6:53 pm, edited 1 time in total.
you probably forgot to quote the property-values
In case of doubt, quote all values.
Code: Select all
<html>
<head>
<title>quote the properties</title>
</head>
<body>
<pre><?php print_r($_POST); ?></pre>
<form method="POST" action="<?php echo $_SERVER['PHP_SERVER']; ?>">
<select name="aName">
<option value=this is without quotes and will fail>without quotes</quote>
<option value="this is with quotes">with quotes</quote>
</select>
<input type="submit" />
</form>
</body>
</html>- cookie_monster
- Forum Newbie
- Posts: 5
- Joined: Sat Apr 12, 2003 8:41 am
- Location: Australia
Still does it
It still only send the first word from the option menu. Here is the code and the print_r($_POST) stuff
Here is the print_r($_POST) stuff
Array
(
[id] =>
[title] => Example title
[date] => 2002-04-22
[file] => Advance
[content] => Testing content
[Submit] => Submit
)
The file should have been "Advanced Flooring race.JPG"
Code: Select all
<form action="news_process.php" method="post" name="form1">
<blockquote>
<div align="left">
<input type="hidden" name="id" value="<? echo $news_rowї'id']; ?>">
</div>
<p align="left"><i> <span class="smallheading">Title</span></i><br>
<input name="title" type="text" id="title" size="80" value="<? echo $news_rowї'title']; ?>">
</p>
<p align="left"><span class="smallheading"><i>Date (yyyy-mm-dd)</i></span><i><br>
<input name="date" type="text" id="date" value="<? echo $news_rowї'date']; ?>">
</i></p>
<p align="left"><span class="smallheading"><i>Image</i></span><i><br>
<!-- This is the options which gabs image file name from a database -->
<select name="file" id="file">
<option selected><? echo $news_rowї'image1']; ?></option>
<?php
$images_result=mysql_query("SELECT file, title FROM tbl_images");
while($images_row=mysql_fetch_array($images_result))
{
echo("<option value=" . $images_rowї'file'] . ">" . $images_rowї'file'] . "</option>");
}
?>
</select>
<a href="upload.php" class="body">Upload New Image</a></i></p>
<p align="left"><span class="smallheading"><i>Content</i></span><i><br>
<textarea name="content" cols="80" rows="10" id="content"><? echo $news_rowї'content']; ?></textarea>
</i></p>
<p align="left"><i>
<input type="reset" name="Reset" value="Clear">
<input type="submit" name="Submit" value=" Submit ">
<input name="type" type="submit" value="Delete">
</i></p>
</blockquote>
</form>Array
(
[id] =>
[title] => Example title
[date] => 2002-04-22
[file] => Advance
[content] => Testing content
[Submit] => Submit
)
The file should have been "Advanced Flooring race.JPG"
the property is not quoted. I do not refer to php's point of view but to the client's.echo("<option value=" . $images_row['file'] . ">" . $images_row['file'] . "</option>");
Th client receives something like
Code: Select all
<option value=the value of images_rowїfile]>the value of images_rowїfile]</option>If what you want to send as the option's value is identical to what is displayed, there's no need for an value-property at all.
Anyway, try
Code: Select all
while($images_row=mysql_fetch_array($images_result))
{
echo '<option value="',$images_row['file'], '">', $images_row['file'], '</option>';
}- cookie_monster
- Forum Newbie
- Posts: 5
- Joined: Sat Apr 12, 2003 8:41 am
- Location: Australia
Doh!
Something so simple.
Thanks for finding the problem volka, sometimes a fresh pair of eyes does the trick.
Is there a PHP scripting program out there that would have picked that up like edit plus?
Joe
Thanks for finding the problem volka, sometimes a fresh pair of eyes does the trick.
Is there a PHP scripting program out there that would have picked that up like edit plus?
Joe
- cookie_monster
- Forum Newbie
- Posts: 5
- Joined: Sat Apr 12, 2003 8:41 am
- Location: Australia
Double Doh
Don't you hate it when you just over look such a simple problem like that expecting yourself not be that careless.