georgee.b Posted February 25, 2009 Share Posted February 25, 2009 I have a list menu that is being populated from a mysql database, it is populating fine, but i can not get the variable sent to the database. It seems that i am unable to identify the exact variable that should be passed My populating code <?php require ("conn.php"); // Opens a connection to a MySQL server $connection=mysql_connect (localhost, $user, $pass); if (!$connection) { die('Not connected : ' . mysql_error()); } // Set the active MySQL database $db_selected = @mysql_select_db($database); if (!$db_selected) { die ('Can\'t use db : ' . mysql_error()); } // Select all the rows in the markers table $query = "SELECT city, id FROM markers order by `city`"; $result = mysql_query($query); if (!$result) { die('Invalid query: ' . mysql_error()); } echo "<select name=\"select\">\n"; while($zeile = mysql_fetch_array($result)){ ?> <option value="<?php echo $zeile['id']; ?>"><?php echo $zeile['city']; ?></option> <?php } ?> </select> my database processing form <?php require ("conn.php"); // Opens a connection to a MySQL server $connection=mysql_connect (localhost, $user, $pass); if (!$connection) { die('Not connected : ' . mysql_error()); } // Set the active MySQL database $db_selected = @mysql_select_db($database); if (!$db_selected) { die ('Can\'t use db : ' . mysql_error()); } $youtube = $_POST['youtube']; $name = $_POST['name']; $comment = $_POST['comments']; $city = $_POST['city']; // Select all the rows in the markers table $query = "INSERT INTO youtube (youtube, name, comment, city) values ('$youtube', '$name', '$comment', '$city')"; $result = mysql_query($query); if (!$result) { die('Invalid query: ' . mysql_error()); } echo "Thank"; ?> it does not register the city in the database, any ideas Link to comment https://forums.phpfreaks.com/topic/146906-cannot-post-data-from-list-menu-which-is-populated-by-mysql/ Share on other sites More sharing options...
napurist Posted February 25, 2009 Share Posted February 25, 2009 The POST variable your looking for is $_POST['select'] not $_POST['city']. The POST's variable in a select box is the select name not the option name. Hope this helps... Link to comment https://forums.phpfreaks.com/topic/146906-cannot-post-data-from-list-menu-which-is-populated-by-mysql/#findComment-771272 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.