×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Code uploads to the server but not inserting to the database

Code uploads to the server but not inserting to the database

Code uploads to the server but not inserting to the database

(OP)
Greetings mates,

I have working on this code since this morning and it has stumped me.

I have the code that is supposed to upload one or more files at same time to the database as well as insert the accompanying records to the database.

The upload part works for the most part.

Here are the issues I have not been able to resolve so far.

1, When I debug the code, the files that get submitted to the database are blank.
Please see the INSERT statement generated from echo statement:

CODE

INSERT INTO bids (BidDate,DueDate,DueTime,BidTitle,BidID,Description,
'BidIDFile','Addend1','SignInSheet','TabSheet'
,Department,Xcontract,
ContactEmail,ContactPhone,NumofBids,AwardDate,
AwardRecip1,BidType,LastUpdate,Notes,BidStatus)
VALUES ('03/27/2015', '03/28/2015','2:00pm',Testing','T8877',
'Testing again','', '','','','','','','','','','',') 

NOTE: I intentionally left the fieldnames blank. Those are populating correctly.

2, As stated, no records are getting submitted to the database.

3, Lastly, I can only get one file to upload at a time. We would like our users to have the ability to submit as many of the those files as possible.

Your input is greatly appreciated.
Some additional relevant code:

CODE

//start creating Addend from position 1 instead of position 0. e.g: Addend1,... Addend6
            $sqlArr['values'][$i += 1]   =   "'".ms_escape_string($_FILES['item']['name'][$i])."'";
            $sqlArr['columns'][]  =   "BidIDFile";
            $sqlArr['columns'][$i]  =   "Addend".$i;
            $sqlArr['columns'][]  =   "SignInSheet";

if(isset($sqlArr['columns'])) {
    $sql="INSERT INTO bids (BidDate,DueDate,DueTime,BidTitle,BidID,Description,,'".implode("','",$sqlArr['columns'])."',Department,Xcontract,ContactEmail,ContactPhone,NumofBids,AwardDate,AwardRecip1,BidType,LastUpdate,Notes,BidStatus)
              VALUES ('$bidDate', '$dueDate','$dueTime',$bidTitle','$bidId','$desc',".implode(",",$sqlArr['values']).", '$dept','$bidContact','$contactEmail','$contactPhone','$numBids','$awardDate','$awardrecip1','$bidType','$lastUpdate','$notes',$status')" ;
    $objQuery = sqlsrv_query($conn, $sql);
    sqlsrv_close($conn);
} ?> 

Thanks in advance for your help

RE: Code uploads to the server but not inserting to the database

Your have a few values missing an apostrophe $bidTitle and $status don't know if they are string or not.

CODE --> php

$sql="INSERT INTO bids (BidDate,DueDate,DueTime,BidTitle,BidID,Description,,'".implode("','",$sqlArr['columns'])."',Department,Xcontract,ContactEmail,ContactPhone,NumofBids,AwardDate,AwardRecip1,BidType,LastUpdate,Notes,BidStatus)
              VALUES ('$bidDate', '$dueDate','$dueTime',$bidTitle','$bidId','$desc',".implode(",",$sqlArr['values']).", '$dept','$bidContact','$contactEmail','$contactPhone','$numBids','$awardDate','$awardrecip1','$bidType','$lastUpdate','$notes',$status')" ; 

If you can't stand behind your troops, stand in front of them.
Semper Fidelis

Jim

RE: Code uploads to the server but not inserting to the database

Oh and you also have 2 commas together in your field list.

If you can't stand behind your troops, stand in front of them.
Semper Fidelis

Jim

RE: Code uploads to the server but not inserting to the database

(OP)
Thanks Jim,

I think that a major part of the problem is here:

CODE

INSERT INTO bids (BidDate,DueDate,DueTime,BidTitle,BidID,Description,'BidIDFile','Addend1','SignInSheet','TabSheet',Department,Xcontract,ContactEmail,ContactPhone,NumofBids,AwardDate,AwardRecip1,BidType,LastUpdate,Notes,BidStatus) VALUES ('03/27/2015', '03/27/2015','2:00pm',Test','7777','Test','', '','','','','','','','','','',') 

See the problem fields:

'BidIDFile',
'Addend1',
'SignInSheet',
'TabSheet'

The should not have single quotes but I could not figure out another way of getting array:

CODE

//start creating Addend from position 1 instead of position 0. e.g: Addend1,... Addend6
            $sqlArr['values'][$i += 1]   =   "'".ms_escape_string($_FILES['item']['name'][$i])."'";
            $sqlArr['columns'][]  =   "BidIDFile";
            $sqlArr['columns'][$i]  =   "Addend".$i;
            $sqlArr['columns'][]  =   "SignInSheet"; 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close