Jump to content

alanl1

Members
  • Posts

    80
  • Joined

  • Last visited

alanl1's Achievements

Member

Member (2/5)

0

Reputation

  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"
×
×
  • 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.