Jump to content

[SOLVED] I'm being stupid and I've overlooked something


haakuturi

Recommended Posts

hey people - first post and I'm making a fool of myself already lol

 

here's my code:

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>CDDB@HOME :: Add New Artist</title>
<meta http-equiv="content-type"
    content="text/html; charset=iso-8859-1" />
</head>
<body>
<?php if (isset($_POST['ArtistName'])):

  // A new author has been entered
  // using the form below.

  $dbcnx = @mysql_connect('xxxxx', 'xxxxx', 'xxxxx');
  if (!$dbcnx) {
    exit('<p>Unable to connect to the ' .
        'database server at this time.</p>');
  }

  if (!@mysql_select_db('cddb')) {
    exit('<p>Unable to locate the ' .
        'database at this time.</p>');
  }

  $name = $_POST['ArtistName'];
  $sql = "INSERT INTO TblArtist SET
      ArtistName='$ArtistName'";
  if (@mysql_query($sql)) {
    echo '<p>New artist added</p>';
  } else {
    echo '<p>Error adding new artist: ' .
        mysql_error() . '</p>';
  }

?>

<p><a href="<?php echo $_SERVER['PHP_SELF']; ?>">Add another artist</a></p>
<p><a href="manageartists.php">Return to artist list</a></p>

<?php else: // Allow the user to enter a new author ?>

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<p>Enter the new artist:</p>
<label>Name: <input type="text" name="ArtistName" /></label><br />
<input type="submit" value="SUBMIT" />
</form>

<?php endif; ?>

</body>
</html>

 

Now what's happening is that when I add a new artist, I'm told that it was successfully added, but when I view the artists, there's a blank space! I haven't got a screenshot of it, but here's the general idea:

 

Manage Artists
Sarah McLachlan Edit Delete
Placebo Edit Delete
Deep Forest Edit Delete
Edit Delete
Enigma Edit Delete
Natalie Merchant Edit Delete
Edit Delete
Edit Delete

 

Any clues? Please? I just know it's something really really obvious that I just can't see :(

Link to comment
Share on other sites

change

  $name = $_POST['ArtistName'];
  $sql = "INSERT INTO TblArtist SET
      ArtistName='$ArtistName'";

to

  $name = $_POST['ArtistName'];
  $sql = "INSERT INTO TblArtist SET
      ArtistName='$name'";

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.