FoxWizzy
FoxWizzy

Reputation: 45

php $_POST not sending full value

update.php

$q = mysql_query("SELECT id FROM performer WHERE username='$user' LIMIT 1") or die("Error : " . mysql_error());
$r = mysql_fetch_assoc($q);
$id = $r['id'];

$query = mysql_query("SELECT baned_c, baned_c2, baned_c3 FROM performer_s WHERE id='$id' LIMIT 1");
$result = mysql_fetch_assoc($query);
if($result['baned_c'] == NULL) { $res1 = "NONE"; } else { $res1 = $result['baned_c']; }

<?php

echo "<form method=post action=insert.php>";

echo "<select name=country>";
echo "<option value=>NONE</option>";
$country = mysql_query("SELECT DISTINCT country_name FROM country_list ORDER BY country_name ASC");
while($next = mysql_fetch_assoc($country))
{
if($next['country_name'] == $res1)
{
    echo "<option selected value=" . $next['country_name'] . ">" .     $next['country_name'] . "</option>";
}
else
{
    echo "<option value=" . $next['country_name'] . ">" . $next['country_name'] . "</option>";
}
}
echo "</select>";
echo "<br /><input type=submit value=Update List />";
echo "</form>";
mysql_close();

insert.php

$country1 = $_POST['country'];
$user = $_SESSION['MM_Username'];
$query = mysql_query("SELECT id FROM performer WHERE username='$user' LIMIT 1") or die("Error : " . mysql_error());
$row = mysql_fetch_assoc($query) or die("Error : " . mysql_error());
$id = $row['id'];
if(isset($country1)) { mysql_query("UPDATE performer_s SET baned_c='$country1' WHERE id='$id'") or die("Error : " . mysql_error()); }

hello 2 all, new here and its nice too meet you.

hope you can help me out

Up here are my 2 pages update.php and insert.php

my problem :

if $country1 = $_POST['country']; is a one word country all is good but if its a two word country $_POST only gives me the first word

$country1 = $_POST['country'];
if its AMERICA its OK
if its REPUBLIC OF KOREA NOT OK i only get REPUBLIC

what can i do ?

Upvotes: 0

Views: 241

Answers (1)

Alejandro Iv&#225;n
Alejandro Iv&#225;n

Reputation: 4061

Try changing:

echo "<option value=" . $next['country_name'] . ">" .     $next['country_name'] . "</option>";

for:

echo "<option value=\"" . $next['country_name'] . "\">" . $next['country_name'] . "</option>";

You are, basically, generating this HTML right now:

<option value=REPUBLIC OF KOREA>REPUBLIC OF KOREA</option>

and you should be generating this HTML:

<option value="REPUBLIC OF KOREA">REPUBLIC OF KOREA</option>

By the way, do the same thing (add the "s) to the other echo (the selected one).

Upvotes: 2

Related Questions