Jump to content

Cannot post data from list menu which is populated by mysql


georgee.b

Recommended Posts

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

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.