jpl225 Posted September 4, 2009 Share Posted September 4, 2009 Hi! I have a problem getting data to form value. Here is part of my code: ---clip---clip---clip---clip---clip---clip---clip---clip---clip---clip---clip $result = mysql_query("SELECT yrityksennimi, yhteyshenkilonimi, yhteyshenkilotitteli, katuosoite, postinumero, postitoimipaikka, maa, puhelin, web, email FROM toimittajat Where yrityksennimi='$_POST[yritys]'"); $a = mysql_fetch_assoc($result); echo $a["yhteyshenkilonimi"]; ---clip---clip---clip---clip---clip---clip---clip---clip---clip---clip---clip And this works fine. I get result: Jukka Norvanto But if I try to put that result to form field: ---clip---clip---clip---clip---clip---clip---clip---clip---clip---clip---clip <tr><td>Yrityksen nimi:</td><td><INPUT TYPE='text' NAME='Yritys' VALUE=" . $a['yhteyshenkilonimi'] ."></td> ---clip---clip---clip---clip---clip---clip---clip---clip---clip---clip---clip I got result: Jukka Somehow the code will cut everything after space away. Any ideas, how to solve this? Jyri Quote Link to comment https://forums.phpfreaks.com/topic/173081-problem-with-spaces-in-form-field/ Share on other sites More sharing options...
bundyxc Posted September 4, 2009 Share Posted September 4, 2009 Relevant code is obviously being clipped. Please post more. Quote Link to comment https://forums.phpfreaks.com/topic/173081-problem-with-spaces-in-form-field/#findComment-912262 Share on other sites More sharing options...
jpl225 Posted September 4, 2009 Author Share Posted September 4, 2009 <?php $yhteys = mysql_connect("localhost","user","xxxx"); if (!$yhteys) { die('Tietokantaan ei saada yhteyttä: ' . mysql_error()); } mysql_select_db("sukellus", $yhteys); if (! @mysql_select_db("sukellus") ) { echo( "<P>Unable to locate the sukellus " . "database at this time.</P>" ); exit(); } //echo "<B>" . $_POST[yritys] . " :n tiedot</B><p>"; $result = mysql_query("SELECT yrityksennimi, yhteyshenkilonimi, yhteyshenkilotitteli, katuosoite, postinumero, postitoimipaikka, maa, puhelin, web, email FROM toimittajat Where yrityksennimi='$_POST[yritys]'"); if (!$result) { echo("<P>Error performing query: " . mysql_error() . "</P>"); exit(); } $a = mysql_fetch_assoc($result); echo $a["yhteyshenkilonimi"]; //while (list($Yritys, $Yhteyshlo, $Titteli, $Katu, $Postinro, $PTP, $Maa, $Puhelin, $Web, $Email) = mysql_fetch_assoc($result)){ echo "<form action='addseller.php' method='post'> <table> <tr><td>Yrityksen nimi:</td><td><INPUT TYPE='text' NAME='Yritys' VALUE=" . $a['yhteyshenkilonimi'] ."></td> <tr><td>Yhteyshenkilön nimi:</td><td><INPUT TYPE='text' NAME='Yhteyshenkilo' VALUE=" . $Yhteyshlo . "></td> <tr><td>Yhteyshenkilön titteli:</td><td><INPUT TYPE='text' NAME='Titteli' VALUE=" . $Titteli . "></td> <tr><td>Katuosoite:</td><td><INPUT TYPE='text' NAME='Katuosoite' VALUE=" . $Katu . "></td> <tr><td>Postinumero:</td><td><INPUT TYPE='text' NAME='Postinro' VALUE=" . $Postinro . "></td> <tr><td>Postitoimipaikka:</td><td><INPUT TYPE='text' NAME='PTP' VALUE=" . $PTP . "></td> <tr><td>Maa:</td><td><INPUT TYPE='text' NAME='Maa' VALUE=" . $Maa . "></td> <tr><td>Puhelin:</td><td><INPUT TYPE='text' NAME='Puhelin' VALUE=" . $Puhelin . "></td> <tr><td>WWW-osoite:</td><td><INPUT TYPE='text' NAME='Web' VALUE=" . $Web . "></td> <tr><td>Sähköposti:</td><td><INPUT TYPE='text' NAME='Email' VALUE=" . $Email . "></td> </table></form>"; //} ?> Quote Link to comment https://forums.phpfreaks.com/topic/173081-problem-with-spaces-in-form-field/#findComment-912274 Share on other sites More sharing options...
bundyxc Posted September 4, 2009 Share Posted September 4, 2009 Run this, tell me what it says at the bottom: <?php $yhteys = mysql_connect("localhost","user","xxxx"); if (!$yhteys) { die('Tietokantaan ei saada yhteyttä: ' . mysql_error()); } mysql_select_db("sukellus", $yhteys); if (! @mysql_select_db("sukellus") ) { echo( "<P>Unable to locate the sukellus " . "database at this time.</P>" ); exit(); } //echo "<B>" . $_POST[yritys] . " :n tiedot</B><p>"; $result = mysql_query("SELECT yrityksennimi, yhteyshenkilonimi, yhteyshenkilotitteli, katuosoite, postinumero, postitoimipaikka, maa, puhelin, web, email FROM toimittajat Where yrityksennimi='$_POST[yritys]'"); if (!$result) { echo("<P>Error performing query: " . mysql_error() . "</P>"); exit(); } $a = mysql_fetch_assoc($result); echo $a["yhteyshenkilonimi"]; //while (list($Yritys, $Yhteyshlo, $Titteli, $Katu, $Postinro, $PTP, $Maa, $Puhelin, $Web, $Email) = mysql_fetch_assoc($result)){ echo "<form action='addseller.php' method='post'> <table> <tr><td>Yrityksen nimi:</td><td><INPUT TYPE='text' NAME='Yritys' VALUE=" . $a['yhteyshenkilonimi'] ."></td> <tr><td>Yhteyshenkilön nimi:</td><td><INPUT TYPE='text' NAME='Yhteyshenkilo' VALUE=" . $Yhteyshlo . "></td> <tr><td>Yhteyshenkilön titteli:</td><td><INPUT TYPE='text' NAME='Titteli' VALUE=" . $Titteli . "></td> <tr><td>Katuosoite:</td><td><INPUT TYPE='text' NAME='Katuosoite' VALUE=" . $Katu . "></td> <tr><td>Postinumero:</td><td><INPUT TYPE='text' NAME='Postinro' VALUE=" . $Postinro . "></td> <tr><td>Postitoimipaikka:</td><td><INPUT TYPE='text' NAME='PTP' VALUE=" . $PTP . "></td> <tr><td>Maa:</td><td><INPUT TYPE='text' NAME='Maa' VALUE=" . $Maa . "></td> <tr><td>Puhelin:</td><td><INPUT TYPE='text' NAME='Puhelin' VALUE=" . $Puhelin . "></td> <tr><td>WWW-osoite:</td><td><INPUT TYPE='text' NAME='Web' VALUE=" . $Web . "></td> <tr><td>Sähköposti:</td><td><INPUT TYPE='text' NAME='Email' VALUE=" . $Email . "></td> </table></form>"; //} echo "<br /><br />"; echo "What does this say? " . $a['yhteyshenkilonimi']; ?> Quote Link to comment https://forums.phpfreaks.com/topic/173081-problem-with-spaces-in-form-field/#findComment-912280 Share on other sites More sharing options...
jpl225 Posted September 4, 2009 Author Share Posted September 4, 2009 Pekka Jokimies Notice: Undefined variable: Yhteyshlo in C:\wamp\www\test.php on line 78 Notice: Undefined variable: Titteli in C:\wamp\www\test.php on line 84 Notice: Undefined variable: Katu in C:\wamp\www\test.php on line 90 Notice: Undefined variable: Postinro in C:\wamp\www\test.php on line 96 Notice: Undefined variable: PTP in C:\wamp\www\test.php on line 102 Notice: Undefined variable: Maa in C:\wamp\www\test.php on line 108 Notice: Undefined variable: Puhelin in C:\wamp\www\test.php on line 114 Notice: Undefined variable: Web in C:\wamp\www\test.php on line 120 Notice: Undefined variable: Email in C:\wamp\www\test.php on line 126 Yrityksen nimi: Yhteyshenkilön nimi: Yhteyshenkilön titteli: Katuosoite: Postinumero: Postitoimipaikka: Maa: Puhelin: WWW-osoite: Sähköposti: What does this say? Pekka Jokimies Quote Link to comment https://forums.phpfreaks.com/topic/173081-problem-with-spaces-in-form-field/#findComment-912291 Share on other sites More sharing options...
jpl225 Posted September 4, 2009 Author Share Posted September 4, 2009 So MySql will return right info: Pekka Jokimies, but when I try to put it into form value, it will show only Pekka (everything after first space will be removed). $a = mysql_fetch_assoc($result); echo $a["yhteyshenkilonimi"]; Will return Pekka Jokimies, but echo "<form action='addseller.php' method='post'> <table> <tr><td>Yrityksen nimi:</td><td><INPUT TYPE='text' NAME='Yritys' VALUE=" . $a['yhteyshenkilonimi'] ."></td></table></form>"; will return only Pekka So the problem is in that form -clause? Jyri Quote Link to comment https://forums.phpfreaks.com/topic/173081-problem-with-spaces-in-form-field/#findComment-912295 Share on other sites More sharing options...
Mark Baker Posted September 4, 2009 Share Posted September 4, 2009 Does the full name appear if you "view source"? Do you have any styles associated with the form that might be fixing the width, and hiding any overflow Quote Link to comment https://forums.phpfreaks.com/topic/173081-problem-with-spaces-in-form-field/#findComment-912300 Share on other sites More sharing options...
JonnoTheDev Posted September 4, 2009 Share Posted September 4, 2009 You have not contained the value of the text element within quotes correctly. This is the case with all of your form elements. Validate your HTML: <?php echo "<tr><td>Yrityksen nimi:</td><td><INPUT TYPE='text' NAME='Yritys' VALUE='".$a['yhteyshenkilonimi']."'></td>"; ?> Cleaner html should use double quotes for html attributes i.e <?php echo "<tr><td>Yrityksen nimi:</td><td><INPUT TYPE=\"text\" NAME=\"Yritys\" VALUE=\"".$a['yhteyshenkilonimi']."\"></td>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/173081-problem-with-spaces-in-form-field/#findComment-912301 Share on other sites More sharing options...
jpl225 Posted September 4, 2009 Author Share Posted September 4, 2009 Thank you! That solved my problem! Jyri Quote Link to comment https://forums.phpfreaks.com/topic/173081-problem-with-spaces-in-form-field/#findComment-912311 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.