Jump to content


Photo

I wrote my own advertisements script...


  • Please log in to reply
1 reply to this topic

#1 pixy

pixy
  • Members
  • PipPipPip
  • Advanced Member
  • 295 posts

Posted 13 June 2006 - 02:09 PM

Alrighty, I know it's connected because if it couldn't connect to the database it has an error message to give me. So, the problem is when I attempt to add a new advertisement, it tells me table 'ads.danceinside_monica' doesn't exist. However, I know table 'ads' exists, but it shouldn't be concatenating the two...

This is my code for ads.php?action=add. Please tell me if you see something I dont--because I've been trying to get to this work. O_O

elseif ($action=='add') {
    $errors = array(); 
        if (isset($_POST['submitted'])) {
            if (empty($_POST['name'])) {
                $errors[] = 'You forgot to enter a name!';
            } 
            else {
                $name = $_POST['name']; 
            }
            if (empty($_POST['banner'])) {
                $errors[] = 'You forgot to link to a banner!';
            } 
            else {
                $banner = $_POST['banner']; 
            }
            if (empty($_POST['url'])) {
                $errors[] = 'You forgot to enter a url!';
            } 
            else {
            $url = $_POST['url']; 
            }

// Check for errors in the $errors array
                if (empty($errors)) {
                   $query = "INSERT INTO ads (name, banner, url) VALUES ('$name', '$banner', '$url')"; 
                   $result = @mysql_query($query) or die(mysql_error()); 
                   if ($result) {
                       echo "<b>Advertisements updated successfully!</b><p>
                       If you would like to add another banner, <a href=\"ads.php?action=add\">click here</a>."; 
                       mysql_free_result ($result); 
                       mysql_close();
                    } 
                    else {
                       print 'Couldn\'t insert information into database.';
                   }
                } 
                else {
                    print '<b>Error!</b><br>'; 
                    foreach ($errors as $msg) {
                        echo "- $msg<br>";
                    }
                    mysql_free_result ($result); 
                    mysql_close(); 
               }
    } 
    else {
        print "To add a new banner, fill in the information below:"; 
        echo '<form action="ads.php?action=add" method="post">
        <b>Name:</b> <input type="text" name="name" size="15">
        <br><b>Banner Img:</b> <input type="text" name="banner" size="15" value="http://">
        <br><b>Links to:</b> <input type="text" name="url" size="15" value="http://">
        <input type="hidden" name="submitted" value="TRUE">
        <center><input type="submit" name="submit" value="Add New Advertisement"></center></form>'; 
    }
}

This is a .44 Caliber Loveletter straight through my heart.

Tabulas + Threadless + Hire Me!


#2 pixy

pixy
  • Members
  • PipPipPip
  • Advanced Member
  • 295 posts

Posted 14 June 2006 - 10:03 PM

Bump? Does anyone know why I'm having this problem?

This is a .44 Caliber Loveletter straight through my heart.

Tabulas + Threadless + Hire Me!





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users