in the following piece of code the else part of my if/else statements doent seem to work it just adds nothing, thanks.

btw genre is a dropbox (and yes i have added the values) and genre2 is a text box, same with the filehost and filehost2.

$name      = $_POST['song'];
$artist    = $_POST['artist'];
$genre     = $_POST['genre'];
$genre2    = $_POST['genre2'];
$filehost  = $_POST['filehost'];
$filehost2 = $_POST['filehost2'];
$link      = $_POST['link'];

if($genre="other")
{$genre=$genre2;} 
else{$genre=$genre;}

if($filehost="other")
{$filehost=$filehost;} 
else{$filehost=$filehost;}


	$con = mysql_connect('localhost',$username,$password);
	@mysql_select_db($database) or die( "Unable to select database");
	$sql = "INSERT INTO `songs` VALUES ('','$name','$artist','$genre','$filehost','$link')";
	$query = mysql_query($sql) or die('Error: ' . mysql_error());

Hi there,

I think the problem is the syntax in those conditional statements. In PHP, one equals sign sets a variable, but in this case you're wanting to compare two variables. This is done by two equals sign and your code should be like this:

if ($genre == "other") {
  $genre = $genre2;
} else {
  $genre = $genre;
}

if ($filehost == "other") {
  $filehost = $filehost2;
} else {
  $filehost = $filehost;
}
commented: thanks +1

both else statements are redundant
else
blue = blue

Thanks antwan that was the problem.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.