[SOLVED]Checking Existance
Posted: Sun Jan 11, 2004 5:49 pm
I have the following code. When I try to input a song that already exists in the database, the screen should display " You have tried to add a song that is already in the Music Database..." and redirect back to the form page...but instead, all it does is display a white screen. When I try to input a song that hasn't already been entered into the database, everything works fine. Please have a look at me code and tell me what is wrong...
Code: Select all
<?php
include('banned.php');
?>
<?php
$tester = isset($_SESSION["username"]);
if ( $tester == false ) {
header("Location: loginform.php");
}
$dbname = 'eckmusic';
$artist = $_POST['artist'];
$artist = sqlite_escape_string($artist);
$songname = $_POST['songname'];
$songname = sqlite_escape_string($songname);
$user = $_SESSION["username"];
$user = sqlite_escape_string($user);
$dte = date("F j, Y, g:i a");
$dte = sqlite_escape_string($dte);
$url = $_POST['url'];
$url = sqlite_escape_string($url);
$cookiename = $artist.$songname;
if ($db = sqlite_open($dbname, 0666, $sqliteerror)){
$sql = "SELECT cookiename FROM music2 WHERE cookiename = '$cookiename'";
$sql_result = sqlite_query($db, $sql);
if (sqlite_num_rows($sql_result) != 1) {
sqlite_query($db, "insert into music2
(artist, songname, url, cookiename, dte, whoadded)
values ('$artist', '$songname', '$url', '$cookiename', '$dte', '$user')");
?>
<meta http-equiv="REFRESH" content=".1;URL=addmusic.php">
<?php
} else {
die ($sqliteerror);
}
} else {
?>
<body bgcolor="black">
<font color="white">
You have tried to add a song that is already in the Music Database...
<meta http-equiv="REFRESH" content="3;URL=addmusic.php">
<?php
}
?>