Hi there i am a newbie to PHP and MYSql, I made some PHP pages and a MYSQL database a couple of years ago to catalogue my mp3 collection on discs i have. It worked fine. While changing computer a while back I didn't save all the data and so when deciding to get back to this project the other day I had to make up a new datsbase structure.
Anyway to cut a long story short, the PHP pages now dont seen to add an album -error "Album was not added due to an error", display the search results ( I can add data in PHPMYAdmin or command line ok)
Here is the add album verification page....
-----------------------
$dbc=@mysql_connect(DB_HOST,DB_USER,DB_PASSWORD) or die ('Could not connect to MySQL: '.mysql_error());;
@mysql_select_db(DB_NAME) or die ('Could not select the database: '.mysql_error());
if(isset($_POST['Submit'])){ //If form has been submitted
// Album name
if(!empty($_POST['title'])){
$alb=$_POST['title'];
}else{
$alb=FALSE;
echo'<p>Please enter the album name</p>';
}
//ok upto here
//Artist
//Check for new or existing artist
if($_POST['artist']=='newartist'){
//If its a new artist check that an artists name has been typed and add that artist to the database
if(!empty($_POST['newartist'])){
$newart=$_POST['newartist'];
$query="INSERT INTO artist(art_id,artist) VALUES(NULL, '$newart')";
$result=@mysql_query($query);
$artists_id=@mysql_insert_id();
}else{
$artists_id=FALSE;
echo'<p>Please enter the artists name</p>';
}
}elseif($_POST['artist']=='existingartist'){
//If its an existing artist check that an artist has been selected from the pull down menu
if($_POST['exsistingartist']>0){
$artists_id=$_POST['exsistingartist'];
echo"$artists_id";
}else{
$artists_id=FALSE;
echo'Please pick an artist from the pull down menu';
}
}else{
//if no artist type is picked
$artists_id=FALSE;
echo'Please choose an existing or new artist';
}
//ok upto here
//Disc
if($_POST['disc']=='newdisc'){
if(!empty($_POST['newdisc'])){
$newdisc=$_POST['newdisc'];
$query="INSERT INTO disc(disc_id,disc) VALUES('$newdisc', '$newdisc')";
$result=@mysql_query($query);
$disc_id=@mysql_insert_id();
echo'<p>new disc added</p>';
}else{
$disc_id=FALSE;
echo'Please enter the disc number.';
}
}elseif($_POST['disc']=='existingdisc'){
if(!empty($_POST['existingdisc'])){
$disc_id=$_POST['existingdisc'];
}else{
$disc_id=FALSE;
echo'Please enter the disc number';
}
}
//ok upto here
//Genre
if($_POST['genre']){
$gen=$_POST['genre'];
}else{
$gen=FALSE;
echo'Please choose a genre';
}
//ok upto here
//Year (not necessary)
if(!empty($_POST['year'])){
$year=$_POST['year'];
echo"<p>$year</p>";
}else{
$year=' ';
}
//ok upto here
//If we have everything we need then add the album to the database
if($alb && $artists_id && $disc_id && $gen){
$query="INSERT INTO album(alb_id,art_id,gen_id,disc_id,year,title) VALUES (NULL, '$artists_id', '$gen', '$disc_id',''$year',$alb')";
if($result=@mysql_query($query)){
echo'The album has been added';
}else{
echo'Album was not added due to an error';
}
}else{//if we don't have everything we need
echo'Please fill in the missing information';
}
//if forms not submitted
}else{
echo'Please fill in the form';
}
?>
<p><a href="add_album.php">Add another album
</a></p>
<p><a href="../search/search.php">Search </a></p>
</BODY>
</HTML>
----------
Thank you in advance