any PHP experts here?

Discussion in 'Programming' started by Chenks, Oct 1, 2015.

Share This Page

  1. Chenks

    Chenks Registered Trader

    Joined:
    Jan 5, 2002
    Messages:
    3,741
    Likes Received:
    0
    OK so i have a PHP script that uploads a file (all working ok so far).
    i want to added a bit at the end that, upon successful upload, it runs an SQL query (INSERT INTO blah blah)

    i'm just not sure how to do this correctly (if it was ASP then it would be no problem).

    so here is what i have

    Code:
    
    
     
  2. Chenks

    Chenks Registered Trader

    Joined:
    Jan 5, 2002
    Messages:
    3,741
    Likes Received:
    0
    think i've worked it out.
    i added

    Code:
            $query = "INSERT INTO blah blah";
    
            $stmt = sqlsrv_query( $conn, $query );
            if( $stmt === false ) {
             die( print_r( sqlsrv_errors(), true));
            }
    
     
  3. for_the_horde

    for_the_horde New Member

    Joined:
    Sep 10, 2015
    Messages:
    13
    Likes Received:
    0
    Or to make less lines you could try this

    // if everything is ok, try to upload file } else { if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) { echo "The file has been uploaded.

    "; echo "File Name : ". basename( $_FILES["fileToUpload"]["name"]). "
    "; echo "Category : ". $category."
    "; echo "Call Ref: ". $callRef."
    "; echo "Uploaded By: ". $loggedinuser; $query = "INSERT INTO blah blah"; sqlsrv_query( $conn, $query ); ........