Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Apr 2008
    Posts
    46
    Thanks
    1
    Thanked 0 Times in 0 Posts

    FORM - send image in different table then datas

    There are actually TWO INSERT commands. I would need to put them IN ONE INSERT.
    But how?

    PHP Code:
    // ------ FIRST INSERT

        
    if ($action=="adsadd")
        {
     if (
    $_POST['MAX_FILE_SIZE'] >= $_FILES['file']['size']) {
              
    //print_r($_FILES);
                
    mysql_connect("localhost""user""password") or die(mysql_error());
              
    mysql_select_db("Sql191979_4");
               
    $photo addslashes(fread(fopen($_FILES['file']['tmp_name'], "r"), $_FILES['file']['size']));
               
    $query sprintf("INSERT INTO classified(Image, FileType) VALUES
    ('%s', '%s')"
    $photo$_FILES['file']['type']);
               if (
    mysql_query($query)) {
                
    $messages[] = "Your files is successfully store in database"
               } else {
                
    $messages[]= mysql_error();
               }
              } else {
               
    $messages[]="The file is bigger than the allowed size please resize";
              }
       
           if (isset(
    $messages)) { 
            foreach (
    $messages as $message) {
             print 
    $message ."<br>";
            } 
    }

    $link_name strip_tags($link_name);
    $link_desc strip_tags($link_desc);
    $price strip_tags($price);
    $personal_name strip_tags($personal_name);
    $address strip_tags($address);
    $telephone strip_tags($telephone);
    $city strip_tags($city);
    $web_page strip_tags($web_page);
    $picture strip_tags($picture);

    exit;
    }

    // -------- SECOND INSERT

    $rime1 "INSERT into classified VALUES ('NULL','$cat_id','$link_name','$link_desc','$price','$personal_name','$address','$telephone',
    '$result_email','$country','$state','$city','$today','$expires','$web_page','$picture','yes','$result_gold','0')"
    ;
    $rime=$rime;
    $result mysql_query($rime1); 
    Last edited by niko-cola; 05-19-2008 at 08:37 AM. Reason: modified some code which can help to find the error

  • #2
    New Coder
    Join Date
    Apr 2008
    Posts
    46
    Thanks
    1
    Thanked 0 Times in 0 Posts
    why nobody answers me? oh <? echo "pour me....";?>

  • #3
    Regular Coder
    Join Date
    Sep 2006
    Location
    Vermont, USA
    Posts
    154
    Thanks
    0
    Thanked 6 Times in 6 Posts
    um... put the 2nd query before the exit inside the if condition? That code is near unreadable by the way...
    Active PHP/MySQL application developer available for immediate work.
    syosoft.com mavieo.com - Remote Web Site Administration Suite - Reseller Ready

  • #4
    New Coder
    Join Date
    Apr 2008
    Posts
    46
    Thanks
    1
    Thanked 0 Times in 0 Posts

    i should have to make one INSERT from the two I actually have

    I checked the full code and the } are not wrong. There is not syntax error. (I just made a copy and paste cancelling some LOONG and unimportant code).
    Could you please make one unique INSERT code from the two INSERTS that I got in the beginning code?


  •  

    Posting Permissions

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