This should be simple I just can’t figure out why it won’t work.
The first query works fine, no problems. Second and third work with the first one if they are used one at a time. What I’m trying to get is:
Enter information about a CD on a form.
Run query to find a match.
If match update number of copies by copies + 1. That works by itself first query.
If no match insert CD information into a new row. That works by itself with first query.
Tried in different order, checking if $reslt and if !$result. Tried if empty. Going to try isset next.
Been beating my head agaisnt a wall no luck. . .
Thanks in advance. BB
[php]
$artist = $_REQUEST [“artist”];
$altartist = $_REQUEST [“altartist”];
if (empty($altartist)){$altartist = $artist;}
$album = $_REQUEST [“album”];
$price = $_REQUEST [“price”];
$genre = $_REQUEST [“genre”];
$media = $_REQUEST [“media”];
$sql = "SELECT * FROM `music` WHERE
`artist/band` = '$artist' AND `album`
= '$album'";
$result = mysql_query($sql);
if ($result) {$sql = mysql_query(“UPDATE music
SET copies
= copies
+ 1 WHERE artist/band
= ‘$artist’ AND album
= ‘$album’”)
or die(mysql_error());}
else{ $sql = mysql_query(“INSERT INTO music
(artist/band
, alt artist
, album
, price
, copies
, genre
, media
)
VALUES (’$artist’, ‘$altartist’, ‘$album’, ‘$price’, ‘1’, ‘$genre’, ‘$media’)”)
or die(mysql_error());}
mysql_free_result($result);
exit;[/php]