PHP - Long Running Script
I've written a script thats going to take a really long time to execute... Whats the best way to do this as far as the server not timing out?
My script is calculating some statistics based on other tables in the database and then storing them in another table. The results are going to be hundreds of thousands or maybe even millions of rows. Similar TutorialsHi, I have a PHP script which I want to run from a different IP on my server. Example of what I want to do: My main ip: 4.5.6.7 Have several IP's on server. I want my PHP script (running from CLI) to use cURL with another IP, ay 4.5.6.9 Is this possible to do? Help would be greatly appreciated! So I have a php script in public_html on my apache server, and it runs a global economy code for my browser game. If I open firefox and go to: http://localhost/Economy.php it runs the code, and it changes all the values in the database properly. How do I get that to run automatically, say every 6 minutes? I have windows so no cron jobs. I went to task scheduler and created a task which I thought would work, and it lists the task as running. But it gives me an error. Event Views: Code: [Select] Log Name: Microsoft-Windows-TaskScheduler/Operational Source: Microsoft-Windows-TaskScheduler Date: 9/28/2011 5:02:37 PM Event ID: 101 Task Category: Task Start Failed Level: Error Keywords: (1) User: SYSTEM Computer: Matt-PC Description: Task Scheduler failed to start "\Economy" task for user "Matt-PC\Matt". Additional Data: Error Value: 2147750687.Event Xml: Code: [Select] <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event"> <System> <Provider Name="Microsoft-Windows-TaskScheduler" Guid="{DE7B24EA-73C8-4A09-985D-5BDADCFA9017}" /> <EventID>101</EventID> <Version>0</Version> <Level>2</Level> <Task>101</Task> <Opcode>101</Opcode> <Keywords>0x8000000000000001</Keywords> <TimeCreated SystemTime="2011-09-28T22:02:37.967669800Z" /> <EventRecordID>18</EventRecordID> <Correlation /> <Execution ProcessID="1012" ThreadID="1484" /> <Channel>Microsoft-Windows-TaskScheduler/Operational</Channel> <Computer>Matt-PC</Computer> <Security UserID="S-1-5-18" /> </System> <EventData Name="TaskStartFailedEvent"> <Data Name="TaskName">\Economy</Data> <Data Name="UserContext">Matt-PC\Matt</Data> <Data Name="ResultCode">2147750687</Data> </EventData> </Event> EDITed for code tags I have a php script that calls another script. It seems that the 2nd script times out or something. I have tried setting max_execution_time to 120 seconds. how can I fix this? I open to anything. Thanks hi
I am having problems trying to either include php file or execute a php script within <div with a class> which I use for a drop down menu, every bit of help much appreciated, thanks..singhy
<h2 class="hidenextdiv"><a href="#">dropdown menu1</a></h2> <div class="another dropmenuclass"> <h3>Test</h3> want to add my php working code here, have tried includes but no joy, it either breaks the dropdown menu or I am not getting the results back from the database, my script works ok, have tested it separately. <h3> </h3> <div style="clear: both;"> </div> </div> Hi, i need some help with my script to take data from mysql database to be used for a login. Created table, with registration, checked passwords and such but the login button when clicked does nothing? please help <?php $username = $_POST['username']; $password = $_POST['upassword']; $self = $_SERVER['PHP_SELF']; $referer = $_SERVER['HTTP_REFERER']; #if either form field is empty return to the log-in page if( (!$username ) or (!$password ) ) { header( "Location:$referer" ); exit(); } #connect to mysql $conn = @mysql_connect( "server", "username", "password ) or die( "Could not connect" ); #select database $rs = @mysql_select_db( "removalspacelogin", $conn ) or die ( "Could not select db" ); #create query $sql="select * from users where username=\"$username\" and password = password( \$password\" )"; #execute query $rs = mysql_query( $sql, $conn ) or die( "Could not execute query" ); #get number of rows that match username and password $num = mysql_numrows( $rs ); #if there is a match the log-in in done if( $num != 0 ) { $msg = "Welcome $username - your log-in was successfull!"; } else #or return to: login.php { header( "Location:www.removalspace.com/wrong.html" ); exit(); } ?> <html> <head><title>Check-login</title></head> <body> <?php echo( $msg ); ?> </body> </html> Hi
I inserted javascript to track google ad conversions inside finalpage.htm which is parte of a major site I which I don’t have access to.
The site manager only allows uploading some .htm pages for customization purposes.
But the scripts are not running anymore.
When I use google label checker plugin to analyse the page, I got the message below:
<script> tag must not be included in a <span>
But the finalpage.htm is a blank page, so there is not <span>
Maybe <span> are coming from a higher level of the website.
Is there I way to prevent this and guarantee my seeing as a real blank page ?
Moises
I am running some php via a cron and I was after the best way to achieve this. Currently I am doing it as follows:- Code: [Select] 0 * * * * lynx -dump http://www.domain.com/script.php This works fine but I don't want anybody being able to run the script by pointing their browser to the file. Any advice on the best method? Cheers. My website is being overrun with spam and I am trying to install a php captcha script. I have installed php 5 on my website askthephysicist.com which is hosted on a 1&1 Windows server, but I think the problem is that I do not know where to point my script to find the lib. I have very little fluency with any scripting languages. Anyhow, the beginning of the script reads: <?php require 'CaptchasDotNet.php'; // Required Parameters // Replace the values you receive upon registration at http://captchas.net. // // client: 'demo' // // secret: 'secret' // and when I run it I get the message: Fatal error: require(): Failed opening required 'CaptchasDotNet.php' (include_path='.:/usr/lib/php5.5') in /homepages/29/d191906528/htdocs/askthephysicist/query.php on line 4 The whole code may be found at http://captchas.net/sample/php/ if that is helpful, but the error occurs with the first statement require 'CaptchasDotNet.php'; I have a script there download a lot of images from a website it crawls, but when ever i started a crawler, it will keep downloading images. Even if i close firefox, it will continue to download images from the site. How can i stop it?. Hey y'all. Probably a dumb question here but I'm at a loss. I've got a PHP service script that has an include, written as so: $config = new Config('config/config.json'); The config directory is next to the PHP script and does contain the config.json file, so when I run this from the CLI everything works great. However, I've got about 17 PHP services I need to start and really don't feel like typing them all out, so I've written a shell script that does this: #!bin/bash cd /path/to/my/script /usr/local/bin/php ./my-script.php This does start the service, but it bombs out because it can't find the config.json file. If I change the PHP to $config = new Config('./config/config.json'); it works as expected from the shell script. Updating the files is technically possible, but fraught right now for reasons I can't really get into (sorry). Anybody know what the difference is, or have any ideas on how to get around this? Edited September 5, 2020 by maxxdI am writing a script which will be dependent on the client's public ip address. e.g.
if the client is using ip address 203.122.55.124 script A should run and if else then script B should run. Now I know that the If and else will be used but cant guess how will the public ip be captured.
Please help
im testing the following script and it wont send 1 2 3 until the script has finished executing. What can i do to flush the buffer after every echo statement?? <?php echo "1"; ob_flush();flush(); sleep(5); echo "2"; ob_flush();flush(); sleep(5); echo "3"; ob_flush();flush(); ?> Hello !
How I can make a script of my PHP code to work even if my website is not running
Can I make this with php ?
I have a php script that I've been running that seems to have been working but now I'm wondering if some of my logic is potentially off. I select records from a db table within a date range which I put into an array called ```$validCount``` If that array is not empty, that means I have valid records to update with my values, and if it's empty I just insert. The trick with the insert is that if the ```STORES``` is less than the ```Quantity``` then it only inserts as many as the ```STORES``` otherwise it inserts as many as ```Quantity```. So if a record being inserted with had Stores: 14 Quantity:12
Then it would only insert 12 records but if it had It would only insert 1 record. In short, for each customer I should only ever have as many valid records (within a valid date range) as they have stores. If they have 20 stores, I can have 1 or 2 records but should never have 30. It seems like updating works fine but I'm not sure if it's updating the proper records, though it seems like in some instances it's just inserting too many and not accounting for past updated records. This is the logic I have been working with:
if(!empty($validCount)){ for($i=0; $i<$row2['QUANTITY']; $i++){ try{ $updateRslt = $update->execute($updateParams); }catch(PDOException $ex){ $out[] = $failedUpdate; } } }else{ if($row2["QUANTITY"] >= $row2["STORES"]){ for($i=0; $i<$row2["STORES"]; $i++){ try{ $insertRslt = $insert->execute($insertParams); }catch(PDOException $ex){ $out[] = $failedInsertStore; } } }elseif($row2["QUANTITY"] < $row2["STORES"]){ for($i=0; $i<$row2["QUANTITY"]; $i++){ try{ $insertRslt = $insert->execute($insertParams); }catch(PDOException $ex){ $out[] = $failedInsertQuantity; } } } }
Let's say customer 123 bought 4 of product A and they have 10 locations
customerNumber | product | category | startDate | expireDate | stores Because they purchased less than their store count, I insert 4 records. Now if my ```$validCheck``` query selects all 4 of those records (since they fall in a valid date range) and my loop sees that the array isn't empty, it knows it needs to update those or insert. Let's say they bought 15 this time. Then I would need to insert 6 records, and then update the expiration date of the other 9 records.
customerNumber | product | category | startDate | expireDate | stores There can only ever be a maximum of 10 (store count) records for that customer and product within the valid date range. As soon as the row count for that customer/product reaches the equivalent of stores, it needs to now go through and update equal to the quantity so now I'm running this but it's not running and no errors, but it just returns back to the command line $total = $row2['QUANTITY'] + $validCheck; if ($total < $row2['STORES']) { $insert_count = $row2['QUANTITY']; $update_count = 0; } else { $insert_count = $row2['STORES'] - $validCheck; // insert enough to fill all stores $update_count = ($total - $insert_count); // update remainder } for($i=0; $i<$row2['QUANTITY']; $i++){ try{ $updateRslt = $update->execute($updateParams); }catch(PDOException $ex){ $failedUpdate = "UPDATE_FAILED"; print_r($failedUpdate); $out[] = $failedUpdate; } } for($i=0; $i<$insert_count; $i++){ try{ $insertRslt = $insert->execute($insertParams); }catch(PDOException $ex){ $failedInsertStore = "INSERT_STORE_FAILED!!!: " . $ex->getMessage(); print_r($failedInsertStore); $out[] = $failedInsertStore; } }```
Visitors to my website will upload file to a simple upload.html: Code: [Select] <form action="execute.php" method="post" enctype="multipart/form-data"> <label for="file">Filename:</label> <input type="file" name="file" id="file" /><br /> <input type="submit" name="submit" value="Submit"" /> </form> As you can see, the arguments are posted to execute.php. In this, I have lines that look like this: Code: [Select] $ob_file = fopen("../../log.txt",'w') or die ("cannot create log.txt"); function ob_file_callback($buffer) { global $ob_file; fwrite($ob_file,$buffer); } ob_start('ob_file_callback'); system ("../../sourceShell") or die ("sourceShell fail") ; ob_end_flush(); execute.php runs a shell script called 'sourceShell', which runs a fortran program on the server. execute.php outputs the 'log' of this program (that typically would appear on the terminal) on log.txt. I use the ob_file_callback function to do this. When a visitor clicks 'submit' (or upon the completion of uploading), I need execute.php to echo "Your job is running..please wait". And then I want to refresh the page every 5 mins until the job finishes and the result will be shown. My problem is that, when a visitor clicks 'submit', it waits until the fortran program completely finishes (which takes a long time) before it outputs the "Your job is running..please wait". I suspect this is because of the ob_file_callback function. If I don't use that function, it seems like the log prints in real time to my browser as the program runs. I do hope this make sense... and I've spent days on this wanting to tear off my hair, so it's not like I haven't googled hard. I'm completely new to web programming, so I hope you guys understand and can be patient if I don't understand. Hi All, I am trying to call a javascript pop-up window via a link by echoing out the html via php but keep getting parse errors: Parse error: syntax error, unexpected ')', expecting ',' or ';' Here is the code in question: Code: [Select] echo "<td class=\"today\"> <a href=\"javascript:statusWindow('status.php?month=".$month."&day=".$day."&year=$year');\">"$day_num</a> </td>\n"; And here is the javascript function: Code: [Select] <script type="text/javascript"> function statusWindow(url){ status_popupWin = window.open(url, 'status', 'resizable=yes, scrollbars=yes, toolbar=no,width=400,height=400'); status_popupWin.opener = self; } </script> Any help is appreciated. Thanks, kaiman Hey Folks This is a major long shot but is their a way that i can use php to upload one mp3 file and one doc file, then get the php script to place the mp3 file in one folder but also copy the mp3 file and make it into a zip file and place it into another folder as well as also make another copy of the mp3 file pair it with the doc file and make it into another zip file in yet another folder mp3->---------------------------->--mp3----------------->----mp3 into zip-------->--mp3 + doc into zip &---- > --Uploaded via php----->--placed in folder a--->----placed in folder b--->--placed in folder c doc-->---------------------------->--copied--------------->----mp3 copied--------->-- But thier is a catch the host i am using didn't activate ZipArchive() function so need a diferent way to make the zip file. Any Ideas people? because i have been pulling my hair out at this one please help Phil I would like to apply some addition functionality to a form which add news records into the database. Basicaly what i want is similar to what this forum does with the [ code ] [ /code ] but what i want for the user to be able to add [ quote ] [ /quote ] and when the post is viewed then that specific area of the acticle body will be formated diffrently. I hope this makes sence. I'm working on a site that provides database results. To get to the final report, I'm going through a few pages where the user selects specific options. This builds up arrays that need to be passed from one page to another. As a result the final page has a pretty lengthy variable list. Since I want to provide a link to certain customers where they don't have to go through all the option select stuff, I'm using the GET method on the final page. Due to all the arrays I need to pass, I'm hitting hyperlink address character limitations, and I fear I will eventually hit browser URL length limits. Is there any way to provide links to customers without using the GET method so I could keep the URL length down? is it possible to get an ajax call to execute a php script that will continue running even if the user leaves my site? i have used cron jobs and tokens to do in past but this can result in 1 min delay. |