Jump to content

alanl1

Members
  • Posts

    80
  • Joined

  • Last visited

Everything posted by alanl1

  1. Hi Professionals I am currently importing spreasheets into our database, however when this is a larger file i get a FastCGI timeout, is there somewhere in any ini files or somewhere like that that this can be increased as I am pretty new to php. error code below Server Error in Application "DEFAULT WEB SITE" Internet Information Services 7.5 Error Summary HTTP Error 500.0 - Internal Server Error C:\PHP 5\php-cgi.exe - The FastCGI process exceeded configured request timeout Detailed Error Information Module FastCgiModule Notification ExecuteRequestHandler Handler PHP via FastCGI Error Code 0x80070102 Requested URL http://localhost:80/cleanse1.php?filename=bhpnewtablepartone.csv Physical Path C:\inetpub\wwwroot\cleanse1.php Logon Method Anonymous Logon User Anonymous
  2. Hi Professionals. Not sure if I have posted in the right place but here goes. I have a prgram that coverts a csv to an array in preperation to make some changes then upload to the database. all works fine until I use a larger csv file then I receive the error HTTP Error 500.0 - Internal Server Error C:\PHP 5\php-cgi.exe - The FastCGI process exited unexpectedly Detailed Error Information Module FastCgiModule Notification ExecuteRequestHandler Handler FastCGI PHP Error Code 0x000000ff Requested URL http://localhost:80/preupload.php Physical Path C:\inetpub\wwwroot\preupload.php Logon Method Anonymous Logon User Anonymous does anyone have any idea what I need to do I have exausted my online help thanks in advance
  3. Hi Profesionals hope i can make sense on this one. I am calling a sp_rename procedure in sqlserver with my php page and it is showing the error on the screen Array ( [0] => Array ( [0] => 01000 [SQLSTATE] => 01000 [1] => 15477 [code] => 15477 [2] => [Microsoft][SQL Server Native Client 11.0][SQL Server]Caution: Changing any part of an object name could break scripts and stored procedures. [message] => [Microsoft][SQL Server Native Client 11.0][SQL Server]Caution: Changing any part of an object name could break scripts and stored procedures. ) ) is there a way to surpress this in php or refresh the screen or jump to another page or something as it is very annoying. apparently it is a compilation error in sqlserver during the renaming of columns which cannot be removed from a database end. thanks
  4. Hi Professionals I am stuck here trying to retrieve some values and update the DB I have a dynamic drop down box that is created within my loop on the first page like so <select name="<?php echo "dropdown[" .$c ."]" ?>" id="<?php echo $data[$c] ?>" ><?php echo "<option value='y'>Keep Existing</option>"; echo "<option value='n'>Ignore</option>"; echo "<option value='tick'>Cleanse</option>"; ?></select> When I click view source I get <select name="dropdown[0]" id="SoftwareManufacturer" ><option value='y'>Keep Existing</option><option value='n'>Ignore</option><option value='tick'>Cleanse</option></select> I can pull the name out no problem, but what I am looking for is to retrieve the ID as that is my actual db column name so I would need to update that column in the DB. for instance if the dropdown name = y then update db set (ID of the dropdown to something) hope this makes sense foreach ($_POST['dropdown'] as $numcolumns=>$downboxValue) { if($downboxValue === 'y') /*This is set to KEEP EXISTING so we need to keep this spreadshet column */ { echo "this is a y" .$downboxvalue; } elseif($downboxValue === 'n') /*This is set to IGNORE so we need to drop this spreadshet column */ { echo "this is a n" .$downboxvalue; } else /*This is set to a TICK so we need to cleanse this db value */ { echo "this is a tick" .$downboxvalue; } }
  5. I have managed to get this to display by doing amending the column in the DB to date and also changing the query to CONVERT(varchar, DATEPART(dd, Tdate)) + '/' + CONVERT(varchar, DATEPART(mm, Tdate)) + '/' + CONVERT(varchar, DATEPART(yyyy, Tdate)) as Tdate just one question, how do i actually set error_reporting set to E_ALL and display_errors set to ON so that php will help me in displaying the errors it detects?
  6. sorry yes that code should be there that is just a copy and past error when I was showing example. it should be fputcsv($handle, array($row['businessunit'],$row['costcentre'],$row['Tdate'])); do you think it could be something to do with the quotes with the dat conversion? regards
  7. Hi All I have been writing my DB values to a csv without any problems until now. When I extract a date field it does not write to the file. Please find below the code that works and the code that does not work working while($row = sqlsrv_fetch_array($exportquery1)) { fputcsv($handle, array($row['businessunit'],$row['costcentre'])); } // Finish writing the file fclose($handle); not working while($row = sqlsrv_fetch_array($exportquery1)) { fputcsv($handle, array($row['businessunit'],$row['costcentre'],$row['Tdate])); } // Finish writing the file fclose($handle); any ideas what I would need to do, when I query within the backend database it is fine
  8. fantastic that works, just one thing though my output in the csv file is like so. Column1, Column2, column1 data, column2 data,column1 data2ndrow, column2data2ndrow and so on I would prefer it to be Column1, Column2 column1 data, column2 data column1 data2ndrow,column2data2ndrow and so on Is there a way to put in a new line character
  9. Hi Professionals. I am trying to write records from the DB into a spreadsheet, but when I open this there is only the titles, could I be missing something here. I have tested my query in the backend database and it works fine. Here is my code so far. <?php // Connect and query the database include("header.php"); include("footer.php"); include("ConnectDB.php"); $sql = "SELECT productdescription, activeqty FROM SARTable ORDER BY productdescription"; $stmt = sqlsrv_query( $conn, $sql); /* Check the database connection is good */ /*******************************************************/ if( $conn === false) { die( print_r( sqlsrv_errors(), true) ); } /* Prepare the Create table statement. */ /*******************************************************/ if(!$stmt = sqlsrv_prepare( $conn, $sql)) { die( print_r( sqlsrv_errors(), true)); } /* Execute the Create table statement. */ if( !sqlsrv_execute( $stmt)) { die( print_r( sqlsrv_errors(), true)); } // Pick a filename and destination directory for the file // Remember that the folder where you want to write the file has to be writable $newfilename = "Test.csv"; $filename = "C:\\inetpub\\wwwroot\\cleansed\\".$newfilename; echo $filename; // Actually create the file // The w+ parameter will wipe out and overwrite any existing file with the same name $handle = fopen($filename, 'w+'); // Write the spreadsheet column titles / labels fputcsv($handle, array('productdescription','activeqty')); // Write all the user records to the spreadsheet foreach($stmt as $row) { fputcsv($handle, array($row['productdescription'], $row['activeqty'])); } // Finish writing the file fclose($handle); sqlsrv_free_stmt( $stmt); ?>
  10. thank you for your quick response, that has solved my problem thanks again
  11. Hi All I am doing a str_replace for different values that need to be replaced within my variable like so $datadownboxValue = str_replace(' ', '_', $datadownboxValue); $datadownboxValue = str_replace('-', '_', $datadownboxValue); $datadownboxValue = str_replace('/', '_', $datadownboxValue); can this be done easier EG all in one rather than repeat for each different value thanks in advance
  12. Hi Professionals. I have some code that puts a csv file into an array, this works great for lots of different files, with the expetion with one file that will not work. I think it may be a permissions problem. anyway here is my code, I have taken out all the javascript funtions to make it more readable. Is there any way the permissions can be changed, when I went and manually checked the file i tried to open it in notepad and it said access denied. I am not to good with windows but anyway I changed the permissions and was able to open it with notepad successfully, however it still looks like its not opening via my code. <?php $newname = $_GET['newname']; $filename = basename($newname,"/"); //basename function strips the "/" to retreive just filename from the Uploads folder... ?><form method='POST' name="myform" action="cleanse.php?filename=<?php echo htmlentities(urlencode($filename)); ?>" ><?php // Counter variable necessary for dynmaic drop down box on javascript client side function $counter = 1; echo "About to open file " .$filename; if (($handle = fopen($filename, "r")) !== FALSE) { $length = 1000; $delimiter = ","; $rows = 0; while ( ( $data = fgetcsv( $handle, $length, $delimiter ) ) !== FALSE ) { if( $rows == 0 ) { $num = count($data); echo "<table width=100% border=0>"; echo "<tr width=100% align=center><td colspan=4>&nbsp</td></tr>"; echo "<tr width=100% align=center><td colspan=4 style=white-space:nowrap;width:100%;></td></tr>"; echo "<tr width=100%><td width=25%>&nbsp</td><td width=20%>&nbsp</td><td width=15%> </td><td width=40%> </td></tr>"; echo "<tr width=100%><td width=25% align=right>&nbsp</td><td colspan=3>Selecting one to many allows for 3 columns, De-selecting one to many only allows the first set of columns</td></tr>"; echo "<tr width=100%><td width=25% align=right>&nbsp</td><td colspan=3>&nbsp</td></tr>"; echo "<tr width=100%><td width=25% align=right>&nbsp</td><td width=20%>"; echo "<input type=checkbox id=cbox name=cbox value=unselected onclick=show_hide(this.checked);>One to many</td>"; //One to many checkbox echo "<td width=15%> </td><td width=40%> </td></tr>"; echo "<tr width=100%><td width=25%> </td><td width=20%>&nbsp</td><td width=15%> </td><td width=40%> </td></tr></table>"; for ($c=0; $c < $num; $c++) { echo "<table width=100% border=0><tr width=25% align=right><td>"; //Second array element populates the dropdown and calculates the number of columns from spreadsheet for ($d=0; $d < $num; $d++) { //echo "<option value='" .$data[$d]."'>" .$data[$d]."</option>"; } ?><input type="text" name="<?php echo "textbox[" .$c ."]" ?>" id="<?php echo "textbox[" .$data[$c]."]" ?>" value="<?php echo $data[$c] ?>" readonly style="background-color:White; color:Black;"> <?php echo "<td width=20% align=left>"; ?> <---- Matches to -----> <select name="<?php echo "dropdown[" .$c."]"?>" onchange="fillSelect(this,categories[this.value],'<?php echo "dropdown" .$counter++ ?>')"><?php echo "<option selected>Please Choose</option>"; echo "<option value='Software Manufacturer" .$c. "'>Software Manufacturer</option>"; echo "<option value='Product Name" .$c. "'>Product Name</option>"; echo "<option value='Product Version" .$c. "'>Product Version</option>"; echo "<option value='Keep Existing'>Keep Existing</option>"; echo "<option value='Ignore'>Ignore</option>"; ?></select><?php echo "</td><td width=15% align=left>"; ?> <select name="<?php echo "secondDD[" .$c ."]" ?>" id="<?php echo "secondDD[" .$c."]" ?>" style="display:none;" ><?php echo "<option selected>Please Choose</option>"; echo "<option value='Software Manufacturer2" .$c. "'>Software Manufacturer</option>"; echo "<option value='Product Name2" .$c. "'>Product Name</option>"; echo "<option value='Product Version2" .$c. "'>Product Version</option>"; echo "<option value='Keep Existing2" .$c. "'>Keep Existing</option>"; echo "<option value='Ignore2" .$c. "'>Ignore</option>"; ?></select><?php echo "</td><td width=40% align=left>"; ?> <select name="<?php echo "thirdDD[" .$c ."]"?>" id="<?php echo "thirdDD[" .$c."]" ?>" style="display:none;"><?php echo "<option selected>Please Choose</option>"; echo "<option value='Software Manufacturer3" .$c. "'>Software Manufacturer</option>"; echo "<option value='Product Name3" .$c. "'>Product Name</option>"; echo "<option value='Product Version3" .$c. "'>Product Version</option>"; echo "<option value='Keep Existing3" .$c. "'>Keep Existing</option>"; echo "<option value='Ignore3" .$c. "'>Ignore</option>"; ?></select><?php echo "</td></tr></table>"; } } $rows++; // ADDED } fclose($handle); } ?><br /><table width="100%" border="0"> <tr> <td width=25% align=center> </td> <td width=25% align=center> </td> <td width=25% align=left><input name="Clean" align="center" type="submit" value="Load"/></td> <td width=25% align=center> </td> </tr> </table> </form> </body> </html>
  13. but it takes less than half a second to run when i run it by itself, when it is in the php exec command it just hangs and hangs until an error is produced HTTP Error 500.0 - Internal Server Error C:\PHP 5\php-cgi.exe - The FastCGI process exceeded configured request timeout
  14. Hi All I have a php exec command which runs SQLCMD as follows the sqlcmd command works great by itself but when i run it in php it hangs, any ideas exec('c:\WINDOWS\system32\cmd.exe /c START C:\inetpub\wwwroot\batchfiles\export.bat'); this runs a sqlcmd batch file as follows sqlcmd -S d3licsql02 -d TestData -U sa -P sqldba -Q "select * from dbo.newtable" -s "," -o "C:\inetpub\wwwroot\cleansed\result.csv"
  15. Hi professionals I have some code as follows /* The queries to be prepared for execution */ /*******************************************************/ $stmt = sqlsrv_query( $conn, $sql); $stmt1 = sqlsrv_query( $conn, $sql1); $droptable1 = sqlsrv_query( $conn, $droptable); $bulkinsert1 = sqlsrv_query( $conn, $bulkinsert); /*******************************************************/ /* Check the database connection is good */ /*******************************************************/ if( $conn === false) { die( print_r( sqlsrv_errors(), true) ); } /*******************************************************/ /* Prepare the drop table query. */ /*******************************************************/ if(!$droptable1 = sqlsrv_prepare( $conn, $droptable)) { echo "Could not prepare statement"; die( print_r( sqlsrv_errors(), true)); } /* Execute the drop table query. */ if( !sqlsrv_execute( $droptable1)) { echo "Error in executing statement.\n"; die( print_r( sqlsrv_errors(), true)); } /*******************************************************/ /* Prepare the Create table statement. */ /*******************************************************/ if(!$stmt = sqlsrv_prepare( $conn, $sql)) { echo "Could not prepare statement"; die( print_r( sqlsrv_errors(), true)); } /* Execute the Create table statement. */ if( !sqlsrv_execute( $stmt)) { echo "Error in executing statement.\n"; die( print_r( sqlsrv_errors(), true)); } /*******************************************************/ /* Prepare the BULK insert statement. */ /*******************************************************/ if(!$bulkinsert1 = sqlsrv_prepare( $conn, $bulkinsert)) { echo "Could not prepare statement"; die( print_r( sqlsrv_errors(), true)); } /* Execute the BULK insert statement. */ if( !sqlsrv_execute( $bulkinsert1)) { echo "Error in executing statement.\n"; die( print_r( sqlsrv_errors(), true)); } /*******************************************************/ /* Prepare the Cleansing data statement. */ /*******************************************************/ if(!$stmt1 = sqlsrv_prepare( $conn, $sql1)) { echo "Could not prepare statement"; die( print_r( sqlsrv_errors(), true)); } /* Execute the Cleansing data statement. */ if( !sqlsrv_execute( $stmt1)) { echo "Error in executing statement.\n"; die( print_r( sqlsrv_errors(), true)); } /******************************************************/ /* Release the Queries */ /*******************************************************/ sqlsrv_free_stmt( $droptable1); sqlsrv_free_stmt( $stmt); sqlsrv_free_stmt( $bulkinsert1); sqlsrv_free_stmt( $stmt1); /*******************************************************/ is there a better way to prepare, execute and realease them rather than repeating them one by one? thanks in advance
  16. I will try and make this a bit easier to understand My loop foreach ($_POST['textbox'] as $datanumcolumns=>$datadownboxValue){ $test = "exec importspreadsheet " . "'" . $newfilename . "'," ."'" .$table_name."'," ."'" .$datadownboxValue."' "; echo $test; //echo "Textbox value" .$datanumcolumns. " has a value of " .$datadownboxValue. " "?><br /><?php } creates exec importspreadsheet 'Synergy_SARnew.csv','newtable','Software Man' exec importspreadsheet 'Synergy_SARnew.csv','newtable','Product Name' exec importspreadsheet 'Synergy_SARnew.csv','newtable','Version Number' exec importspreadsheet 'Synergy_SARnew.csv','newtable','Part Number' exec importspreadsheet 'Synergy_SARnew.csv','newtable','Edition' exec importspreadsheet 'Synergy_SARnew.csv','newtable','Invoice Number' exec importspreadsheet 'Synergy_SARnew.csv','newtable','Supplier' exec importspreadsheet 'Synergy_SARnew.csv','newtable','Purchasing Officer' when I want it to loop through and create exec importspreadsheet 'Synergy_SARnew.csv','newtable','Software Man','Product Name','Version Number','Part Number','Edition','Invoice Number','Supplier','Purchasing Officer' hope this is more meaningful thanks
  17. Hi All I have a loop in php which loops through all the values from a previous page like so foreach ($_POST['textbox'] as $datanumcolumns=>$datadownboxValue){ echo "Textbox value" .$datanumcolumns. " has a value of " .$datadownboxValue. " "?><br /><?php } I also have a sql procedure which passes in variables of 1:csv file 2:table to be created and 3: column count from my loop as shown below $sql = "exec importspreadsheet " . "'" . $newfilename . "'," ."'" .$table_name."'," ."'" .$datanumcolumns."' "; from that within my sql procedure I iterate through the column count and create the database table which builds up a table like so while (@intflag < @column_count-3) begin set @midcolumns = 'colname' + cast(@intflag as nvarchar(2)) + ' nvarchar(max) null,'; set @middlecolumns = @middlecolumns + @midcolumns; set @intflag = @intflag +1; end this produces column1,column2,column3,column4 etc minus my first 3 standard column i have does anyone know if there is a way to pass the actual column values in so for instance if there were 6 columns it would pass in exec impostspreadsheet SPREADSHEETNAME, TABLENAME, Software Man,Product Name,Version Number,Part Number,Edition,Invoice Number the spreadsheet can change so if there were 5 columns then invoice number would not show I hope I make sense
  18. Update FYI I have managed to do this, I changed to a readonly textbox <input type="text" name="<?php echo "textbox[" .$c ."]" ?>" id="<?php echo "textbox[" .$data[$c]."]" ?>" value="<?php echo $data[$c] ?>" readonly="readonly" style="background-color:White; color:Black;">then foreach ($_POST['textbox'] as $datanumcolumns=>$datadownboxValue){ echo "Textbox value" .$datanumcolumns. " has a value of " .$datadownboxValue. " "?><br /><?php }
  19. apparently it is not possible when the text box is set to disabled so i have set this to read only. does anyone know if it is possible now thanks in advance
  20. Hi Doddsey I agree with what your saying but I have no idea how to do that as I am new to php,javascript
  21. Hi All. I have a javascript function that changes the value of the next dropdown box from a list of multiple dropdown boxes based on an onchange event as shown below. What I want to do is if the user selects for instance "software manufacturer" then it is never available again in any of the next dropdown boxes. I can get this to work for the next checkbox but it comes back again for the 3rd checkbox. Hope it makes sense onchange="fillSelect(this,categories[this.value] var categories = []; categories["startList"] = ["Software Manufacturer","Product Name","Product Version","Keep Existing","Ignore"] categories["Software Manufacturer"] = ["Product Name","Product Version","Keep Existing","Ignore"]; categories["Product Name"] = ["Software Manufacturer","Product Version","Keep Existing","Ignore"]; categories["Product Version"] = ["Software Manufacturer","Product Name","Keep Existing","Ignore"]; categories["Keep Existing"] = ["Software Manufacturer","Product Name","Product Version","Keep Existing","Ignore"]; categories["Ignore"] = ["Software Manufacturer","Product Name","Product Version","Keep Existing","Ignore"];
  22. Hi all I have the following code block and on my second page I can pull the values with the second for loop foreach ($_POST[$data] as $datanumcolumns=>$datadownboxValue){ echo "Dropdown array value" .$datanumcolumns. " columns dropdown value " .$datadownboxValue. " "?><br /><br /><?php } foreach ($_POST['dropdown'] as $dropnumcolumns=>$dropdownboxValue){ echo "Dropdown array value" .$dropnumcolumns. " columns dropdown value " .$dropdownboxValue. " "?><br /><br /><?php } trouble is the dropdown box values are showing no problem but the textbox ones are not. could it be that $data variable or something. here is the part of my initial page code block <?php // Two counter variables necessary for looping purposes for dynmaic drop down box javascript client side functions $counter = 1; $counter1 = 1; if (($handle = fopen($filename, "r")) !== FALSE) { $length = 1000; $delimiter = ","; $rows = 0; // ADDED while ( ( $data = fgetcsv( $handle, $length, $delimiter ) ) !== FALSE ) { if( $rows == 0 ) { $num = count($data); for ($c=0; $c < $num; $c++) { echo "<table width=100% border=0>"; echo "<tr width=25% align=right><td>"; for ($d=0; $d < $num; $d++) { //echo "<option value='" .$data[$d]."'>" .$data[$d]."</option>"; } echo "<input type='text' id='".$data[$c]."' value='".$data[$c]."' DISABLED='disabled' style='background-color:White; color:Black;'>"; echo "</td>"; echo "<td width=20% align=left>"; ?> <---- Matches to -----> <select name="<?php echo "dropdown[" .$c."]" ?>" id="<?php echo "dropdown[" .$c."]" ?>" class="nohide" onchange="fillSelect(this,categories[this.value],'<?php echo "dropdown" .$counter++ ?>')"><?php echo "<option selected>Please Choose</option>"; echo "<option value='Manufacturer" .$c. "'>Software Manufacturer</option>"; echo "<option value='Product" .$c. "'>Product Name</option>"; echo "<option value='Version" .$c. "'>Product Version</option>"; echo "<option value='Keep Existing" .$c. "'>Keep Existing</option>"; echo "<option value='Ignore" .$c. "'>Ignore</option>"; ?></select><?php echo "</td>"; echo "<td width=15% align=left>"; ?> <select name="<?php echo "secondDD[" .$c ."]" ?>" id="<?php echo "secondDD[" .$c."]" ?>" style="display:none;" onchange="fillSelect(this,categories[this.value],'<?php echo "secondDD[" .$counter1++ ."]" ?>')"><?php echo "<option selected>Please Choose</option>"; echo "<option value='Manufacturer2" .$c. "'>Software Manufacturer</option>"; echo "<option value='Product2" .$c. "'>Product Name</option>"; echo "<option value='Version2" .$c. "'>Product Version</option>"; echo "<option value='Keep Existing2" .$c. "'>Keep Existing</option>"; echo "<option value='Ignore2" .$c. "'>Ignore</option>"; ?></select><?php echo "</td>"; echo "</tr>"; echo "</table>"; } } $rows++; // ADDED } fclose($handle); }
  23. hi cpd and jessica. apologies that you were unable to understand, I have now solved the problem by pasing the id through
  24. just says there is a syntax error
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.