jaco Posted October 14, 2012 Share Posted October 14, 2012 Hello everyone, this is a rather peculiar problem that I have been banging my head against for a while. I am using an MS database that has pump information, it is converted to a MYSQL database and stored on the server. I use a field of the db to populate an html select widget to select the country of origin this then is used to display more info. Here is a short part of the code that produces the error: <?php // standard html web header require 'header.html'; // html user data input form require 'dbpump.php'; ?> <font size="14"><b>PumP search</b></font> <br /> <br /> <?php $query = "SELECT DISTINCT home_office FROM data ORDER BY home_office ASC"; if(!($connection = @ mysql_connect($hostName,$username,$password))) die("Could not connect"); //select database to edit if(!(@ mysql_select_db($databaseName, $connection))) showerror(); if(!($result = @ mysql_query($query))) showerror(); if(isset($_get['headoffice'])) { //required to recover from server the previous selection $headoffice = $_get['headoffice']; } ?> <form method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <b>Home office country:</b> <select name="headoffice"> <option value="All">All</option> <?php //cycles through all the home office countries in db and lists them in the html select while($row = mysql_fetch_array($result)) { if ($headoffice == $row['home_office']) echo "<option SELECTED value=".$row['home_office'].">".$row['home_office']."</option>"; else echo "<option value=".$row['home_office'].">".$row['home_office']."</option>"; } ///end while mysql_free_result($result); if ($headoffice == "New Jac territory") echo "<option SELECTED value=\"New Jac territory\">New Jac territory</option>"; else echo "<option value=\"New Jac territory\">New Jac territory</option>"; echo "</select>";?> <input type="submit" value="SEARCH"> </form> <br /> <?php //echo $headoffice;?> <?php // standard html web page footer require 'footer.html';?> you run from this web site: http://www.pumpfunda...base2/test2.php What happens is when you select South Africa and you click the Search button, the get function will only transmit the first part of the term or "South" so that you can't do a match to display further information. I typed the country "New Jac territory" directly in the html as the last html select item to appear in the list; this has a couple of blanks and works fine. So it seems that html does not interpret correctly the value coming from the mysql db. I hope I explained this properly. Thanks, Jacques Quote Link to comment https://forums.phpfreaks.com/topic/269455-blank-space-in-access-text-field-not-seen-as-value-in-html/ Share on other sites More sharing options...
Pikachu2000 Posted October 14, 2012 Share Posted October 14, 2012 You need to quote the value= attribute in the <option> tags. Currently, the only one quoted is the one you hard coded the value into. Quote Link to comment https://forums.phpfreaks.com/topic/269455-blank-space-in-access-text-field-not-seen-as-value-in-html/#findComment-1385165 Share on other sites More sharing options...
Christian F. Posted October 14, 2012 Share Posted October 14, 2012 Here is a short part of the code that produces the error: What error? You've done a good job of posting everything else, but without knowing the exact error (message) we're kind of running blind here. Quote Link to comment https://forums.phpfreaks.com/topic/269455-blank-space-in-access-text-field-not-seen-as-value-in-html/#findComment-1385171 Share on other sites More sharing options...
Pikachu2000 Posted October 14, 2012 Share Posted October 14, 2012 What happens is when you select South Africa and you click the Search button, the get function will only transmit the first part of the term or "South" . . The problem is pretty obvious, and my previous post should solve it. Quote Link to comment https://forums.phpfreaks.com/topic/269455-blank-space-in-access-text-field-not-seen-as-value-in-html/#findComment-1385173 Share on other sites More sharing options...
jaco Posted October 14, 2012 Author Share Posted October 14, 2012 Hi, the problem is that when you selct a term with a blank i.e. "South africa" the get function only returns the first part i.e. "South" which is not what is required to make an ID. Pikachu seems to me I do have options tags, can you be more specific. Thanks, Jacques Quote Link to comment https://forums.phpfreaks.com/topic/269455-blank-space-in-access-text-field-not-seen-as-value-in-html/#findComment-1385175 Share on other sites More sharing options...
Pikachu2000 Posted October 14, 2012 Share Posted October 14, 2012 The value= attributes in the <option> tags need to be quoted. Like value="this value". If you look at the html source, you'll see the only one like that is the one you hard coded. The others will be unquoted. Quote Link to comment https://forums.phpfreaks.com/topic/269455-blank-space-in-access-text-field-not-seen-as-value-in-html/#findComment-1385179 Share on other sites More sharing options...
jaco Posted October 14, 2012 Author Share Posted October 14, 2012 My God! Son of a gun! You're right. I guess what through me off is that it works well with a single string with no blanks. What a ya gonna do. Thanks a bunch. Jacques Quote Link to comment https://forums.phpfreaks.com/topic/269455-blank-space-in-access-text-field-not-seen-as-value-in-html/#findComment-1385184 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.