SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict thachp's Avatar
    Join Date
    Aug 2004
    Location
    Seattle
    Posts
    222
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Insert multiple tables error

    Below is my current php script. I was able to use it to insert the first data, but i'm receiving query2 error when i try to add more data. Why? Got altenative suggestions?

    PHP Code:
    <?php
    include 'global.php';

        
    $category   $_POST['category'];
        
    $keyword $_POST['keyword'];
        
    $zone $_POST['zone'];
        
    $link $_POST['link'];
        
    $advertiser $_POST['advertiser'];
        
        if(!
    get_magic_quotes_gpc())
        {
            
    $category   addslashes($category);
            
    $keyword addslashes($keyword);
            
    $zone addslashes($zone);
            
    $link addslashes($link);
            
    $advertiser addslashes($advertiser);
        }
            
        
    $query "INSERT INTO tbl_cats(category) VALUES ('$category')";
        
    $query2 "INSERT INTO tbl_keyword(category,keyword) VALUES ('$category', '$keyword')";
        
    $query3 "INSERT INTO tbl_zone(keyword,zone,links,advertiser) VALUES ('$keyword', '$zone', '$link', '$advertiser')";
        
        
    mysql_query($query) or die('Uh oh! Query failed');
        
    mysql_query($query2) or die('Uh oh! Query 2 failed');
        
    mysql_query($query3) or die('Uh oh! Query 3 failed');
    ?>
    Thank a head.
    Last edited by thachp; Dec 23, 2005 at 07:11. Reason: summary

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,350
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    your mysql looks fine(*)

    moving to php forum


    * other than treating what are undoubtedly numeric columns as character (don't put single quotes around values intended to be inserted into numeric columns)
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •