PHP - Script Stops Running.
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 Similar Tutorialshi, my website is premade website wich i am editing it has these different blocks, and i want to change them in one of those blocks i want a timer that counts down, ive done this with refreshing a div with jquery on other pages, and thats working now i want a downcounting timer in a block, but when i do that another block stops working a block that has a slider of images that slide over ... now i think it has something todo with the document ready function? that stops the other block from working ? u can see it failing here http://www.acidleague.com and this is the code im using inside the block Code: [Select] <script src='http://code.jquery.com/jquery-latest.js'></script> <script> $(document).ready(function() { $('#responsecontainer').load('response.php'); var refreshId = setInterval(function() { $('#responsecontainer').load('response.php'); }, 5000); $.ajaxSetup({ cache: false }); }); </script> <div id="cols-left"> <div class="top_left_block"> <div class="llbg"></div> <div class="top_left_rbg"></div> <div class="rmlbg"></div> <div class="clr"></div> </div> <div style="min-height: 223px;background:#373737;"> <div align="right" style="padding-right:10px;font-size:11px;min-width: 336px;min-height: 44px; background:url(./theme/neo-blue/images/bg/news.png) no-repeat top center transparent;"> <b><span style="color:#055ed5;"><?echo"MINI"?> </span> <?php echo"AGENDA"?></b> </div> <div align="center" style="margin-left:5px; margin-top:-19px;"> <span style="color:#000000;"><b><?php echo"UPCOMING MATCH"?></b></span> <table cellpadding="0" cellspacing="0" width="100%"> <tr> <td> <div id="responsecontainer"></div> </td> </tr> </table> </div> </div> <div class="bot_left_block"> <div class="lbotlbg"></div> <div class="top_bot_lbg"></div> <div class="rbotlbg"></div> <div class="clr"></div> </div> </div> hello, when i add Code: [Select] echo $row['img']; to the code below it prevents it from working correctly. Have I written the line correctly or is there another underlying cause? any help greatly appreciated. working = http://www.1pw.co.uk/demo2.php not working = http://www.1pw.co.uk/demo.php Code: [Select] <?php define('INCLUDE_CHECK',1); require "../#########.php"; if(!$_POST['img']) die("There is no such product!"); $img=mysql_real_escape_string(end(explode('/',$_POST['img']))); $row=mysql_fetch_assoc(mysql_query("SELECT * FROM internet_shop WHERE img='".$img."'")); echo $row['img']; echo '{status:1,id:'.$row['id'].',price:'.$row['price'].',txt:\'\ \ <table width="100%" id="table_'.$row['id'].'">\ <tr>\ <td width="60%">'.$row['name'].'</td>\ <td width="10%">$'.$row['price'].'</td>\ <td width="15%"><select name="'.$row['id'].'_cnt" id="'.$row['id'].'_cnt" onchange="change('.$row['id'].');">\ <option value="1">1</option>\ <option value="2">2</option>\ <option value="3">3</option></slect>\ \ </td>\ <td width="15%"><a href="#" onclick="remove('.$row['id'].');return false;" class="remove">remove</a></td>\ </tr>\ </table>\'}'; ?> not sure if needed but this is the file that includes the above file.... Code: [Select] var purchased=new Array(); var totalprice=0; $(document).ready(function(){ $('.product').simpletip({ offset:[40,0], content:'<img src="img/ajax_load.gif" alt="loading" style="margin:10px;" />', onShow: function(){ var param = this.getParent().find('img').attr('src'); if($.browser.msie && $.browser.version=='6.0') { param = this.getParent().find('img').attr('style').match(/src=\"([^\"]+)\"/); param = param[1]; } this.load('ajax/tips.php',{img:param}); } }); $(".product img").draggable({ containment: 'document', opacity: 0.6, revert: 'invalid', helper: 'clone', zIndex: 100 }); $("div.content.drop-here").droppable({ drop: function(e, ui) { var param = $(ui.draggable).attr('src'); if($.browser.msie && $.browser.version=='6.0') { param = $(ui.draggable).attr('style').match(/src=\"([^\"]+)\"/); param = param[1]; } addlist(param); } }); }); function addlist(param) { $.ajax({ type: "POST", url: "ajax/addtocart.php", data: 'img='+encodeURIComponent(param), dataType: 'json', beforeSend: function(x){$('#ajax-loader').css('visibility','visible');}, success: function(msg){ $('#ajax-loader').css('visibility','hidden'); if(parseInt(msg.status)!=1) { return false; } else { var check=false; var cnt = false; for(var i=0; i<purchased.length;i++) { if(purchased[i].id==msg.id) { check=true; cnt=purchased[i].cnt; break; } } if(!cnt) $('#item-list').append(msg.txt); if(!check) { purchased.push({id:msg.id,cnt:1,price:msg.price}); } else { if(cnt>=3) return false; purchased[i].cnt++; $('#'+msg.id+'_cnt').val(purchased[i].cnt); } totalprice+=msg.price; update_total(); } $('.tooltip').hide(); } }); } function findpos(id) { for(var i=0; i<purchased.length;i++) { if(purchased[i].id==id) return i; } return false; } function remove(id) { var i=findpos(id); totalprice-=purchased[i].price*purchased[i].cnt; purchased[i].cnt = 0; $('#table_'+id).remove(); update_total(); } function change(id) { var i=findpos(id); totalprice+=(parseInt($('#'+id+'_cnt').val())-purchased[i].cnt)*purchased[i].price; purchased[i].cnt=parseInt($('#'+id+'_cnt').val()); update_total(); } function update_total() { if(totalprice) { $('#total').html('total: $'+totalprice); $('a.button').css('display','block'); } else { $('#total').html(''); $('a.button').hide(); } } not sure if this is needed, but it links to the above file; Code: [Select] <?php define('INCLUDE_CHECK',1); require "######.php"; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>shop</title> <link rel="stylesheet" type="text/css" href="demo.css" /> <script type="text/javascript" src="http://code.jquery.com/jquery-1.6.1.min.js"></script> <script type="text/javascript" src="jquery.ui.main.js"></script> <!--[if lt IE 7]> <style type="text/css"> .pngfix { behavior: url(pngfix/iepngfix.htc);} .tooltip{width:200px;}; </style> <![endif]--> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js"></script> <script type="text/javascript" src="simpletip/jquery.simpletip-1.3.1.pack.js"></script> <script type="text/javascript" src="script.js"></script> </head> <body> <div id="main-container"> <div class="tutorialzine"> <h1>Shopping cart</h1> <h3>The best products at the best prices</h3> </div> <div class="container"> <span class="top-label"> <span class="label-txt">Products</span> </span> <div class="content-area"> <div class="content drag-desired"> <?php $result = mysql_query("SELECT * FROM internet_shop"); while($row=mysql_fetch_assoc($result)) { echo '<div class="product"><a href="#" class="item"><img src="img/products/'.$row['img'].'" alt="'.htmlspecialchars($row['name']).'" width="128" height="128" class="pngfix" /></a></div>'; } ?> <div class="clear"></div> </div> </div> <div class="bottom-container-border"> </div> </div> <div class="container"> <span class="top-label"> <span class="label-txt">Shopping Cart</span> </span> <div class="content-area"> <div class="content drop-here"> <div id="cart-icon"> <img src="img/Shoppingcart_128x128.png" alt="shopping cart" class="pngfix" width="128" height="128" /> <img src="img/ajax_load_2.gif" alt="loading.." id="ajax-loader" width="16" height="16" /> </div> <form name="checkoutForm" method="post" action="order.php"> <div id="item-list"> </div> </form> <div class="clear"></div> <div id="total"></div> <div class="clear"></div> <a href="" onclick="document.forms.checkoutForm.submit(); return false;" class="button">Checkout</a> </div> </div> <div class="bottom-container-border"> </div> </div> </div> <div class="bowlpic"> </div> </body> </html> Thanks in advance for any help you can provide on this. Bob G. BACKGROUND: I have an app that is hosted on Host Monster and its script includes a Class that is supposed to send MIME emails with or without attachments using only MIME types text, html, and image. It was working fine. I hadn't worked with or on it for about two months then found, last week, that it would no longer send emails even though the script runs without any Warnings. I've worked on this for several days now and I'm stuck. EXPECTED BEHAVIOR: When the script runs, it should send a simple text only email to a given email address and an more complex email that requires html and an in-line image in the body and an attachment with the same image. The image type is jpeg. ACTUAL BEHAVIOR: The script runs to completion with no Warning but sends neither of the two emails. CODE: Attached and cc'd below is a script which mimics the code in my app and the actual behavior described above but only for the simple email mentioned above. To simplify debug I've commented out that part of the script that should send out the more complex email mentioned above. Note: You can run the script by going to http://www.unitresearch03.com/Admin/SendUserEmailHM01.php Note: Line 6 can be changed to your own email address for testing BEGIN CODE: Code: [Select] <?php //TOP LINE CODE ////SIMPLE MIME EMAIL CODE - NO ATTACHMENTS ////////////////////////////////////////////// $mail = new mime_mail ; $mail->from = "ragsr@ix.netcom.com" ; $mail->to = "ragsr@ix.netcom.com" ; $mail->subject = "SIMPLE MIME EMAIL - NO ATTACHMENTS" ; $mail->body = "SIMPLE MIME EMAIL BODY" ; $mail->send() ; ////END OF SIMPLE MIME EMAIL CODE //////////////////////////////////////////////////////// ////START MIME EMAIL CODE - ALLOWS ATTACHEMENTS ///////////////////////////////////////////////// //SIMPLE SEND EMAIL PG.448 PHP REFERENCE PLUS ATTACHMENT EXAMPLE FROM SAME PAGE //include "mime_mail.inc"; //THIS CAUSED A WARNING AND, APPARENTLY, IS NOT REQUIRED. CODE OK W/O IT //READ FILE $filename="/home1/unitcons/public_html/unitresearch03/TCStripComposition-27Cb.jpg" ; $content_type="image/jpeg" ; //OPEN, EXTRACT DATA, THEN CLOSE FILE $fd=fopen($filename, "r") ; $data=fread($fd, filesize($filename)) ; fclose($fd) ; $fileX="/home1/unitcons/public_html/unitresearch03TCStripComposition-27Cb.jpg" ; $ftype=filetype ($filename) ; $fsize=filesize($filename) ; //echo "FILE TYPE :"."$ftype"."<br>" ; //echo "FD FILE TYPE :"."$fdltype"."<br>" ; //echo "DATA :"."$data"." END DATA"."<br>" ; //echo "FSIZE :"."$fsize"."<br>" ; //echo "FDSIZE :"."$fsize"."<br>" ; //echo "FD :"."$fd"."<br>" ; //CREATE OBJECT INSTANCE $mail = new mime_mail ; //SET ALL DATA SLOTS $mail->from = "thromptmweeklycs@unitresearch03.com" ; $mail->to = "ragsr@ix.netcom.com" ; $mail->subject = "XXXThrompTM Weekly Comic Strip - Week of 6/20/201" ; $mail->body = "<html>Hope you enjoy your ThrompTM today! <br> <br> <br> <img src=http://www.unitresearch03.com/TCStripComposition-27Cb.jpg height='197' width='500' > </html>"; //DEFINE ATTACHMENT $name = $fileX ; $message = $data ; //ADD ATTACHEMENT //$mail->add_attachment ($data, $filename, $content_type) ; //SEND EMAIL //$mail->send() ; ////EBD SEND EMAIL WITH ATTACHMENT ////MIME CLASS class mime_mail { var $parts; var $to; var $from; var $headers; var $subject; var $body ; /* * void mime_mail() * class constructor */ function mime_mail () { $this->parts = array() ; $this->to = "" ; $this->from = "" ; $this->subject = "" ; $this->body = "" ; $this->headers = "" ; } /* * void add_attachement (string message, [string name], [string ctype]) * Add an attachment to the mail object */ function add_attachment ($message, $name = "", $ctype = "text/html jpeg" ) //function add_attachment ($data, $fileX, $content_type ) { echo "CTYPE IN AA :"."$ctype"."<br>" ; //echo "MESSAGE IN AA :"."$message"."<br>" ; echo "ENCODE IN AA: "."$encode"."<br>" ; echo "NAME IN AA :"."$name"."<br>" ; //echo "DATA IN AA :"."$data"."<br>" ; $partsd = $this->parts[] = array ( "ctype" => $ctype, "message" => $message, "encode" => $encode, "name" => $name, ); echo ("ARRAY#1 CTYPE :"."$partsd[ctype]"."<br>") ; //echo ("ARRAY#2 MESSAGE :"."$partsd[message]"."<br>") ; echo ("ARRAY#3 ENCODE :"."$partsd[encode]"."<br>") ; echo ("ARRAY#4 NAME :"."$partsd[name]"."<br>") ; //echo ("ARRAY#5 DATA :"."$partsd[data]"."<br>") ; $sizeX=sizeof($this->parts) ; echo "SIZE OF ARRAY IN ADD ATTACHMENT:"."$sizeX"."<br>" ; } /* * void build_message (array part= * Build message parts of an multipart mail */ function build_message ($part ) { $message = $part[ "message"]; //echo "MESSAGE IN BUILD:"."$message"."<br>" ; $message = chunk_split(base64_encode($message)) ; //echo "MESSAGE :"."$message"."<br>" ; $encoding = "base64" ; $partctype = $part["ctype"] ; $partname = $part["name"] ; echo "PART CTYPE :"."$partctype"."<br>" ; echo "PART NAME :"."$partname"."<br>" ; return "Content-Type: ".$part["ctype"]. ($part["name"]?" ; name =\"". $part["name"]. "\"":""). "\nContent-Transfer-Encoding: $encoding\n\n$message\n" ; } /* * void build_multipart() * Build a multipart mail */ function build_multipart() { $boundary = "b".md5(uniqid(time())) ; $multipart = "Content-Type: multipart/mixed; boundary = $boundary\n\nThis is a MIME encoded message.\n\n--$boundary" ; //$sizeX=sizeof($this->parts) ; //echo "SIZE OF ARRAY :"."$sizeX"."<br>" ; for ($i = sizeof($this->parts)-1; $i >= 0; $i--) { $multipart .= "\n".$this->build_message($this->parts[$i])."--$boundary" ; //echo "MULTIPART :"."$multipart"."<br>" ; } return $multipart.= "--\n" ; } /* * string get_mail() * returns the constructed mail */ function get_mail($complete = true) { $complete = true ; echo "COMPLETE :"."$complete"."<br>" ; ////STAEMENT ADDED TO FORCE IF ($COMPLETE) {} BELOW TO RUN //echo "MESSAGE IN GET MAIL:"."$message"."<br>" ; $mime = "" ; if (!empty($this->from)) $mime .= "From: ".$this->from. "\n" ; echo "MIME 1:"."$mime"."<br>"; if (!empty($this->headers)) $mime .= $this->headers. "\n" ; echo "MIME 2:"."$mime"."<br>"; if ($complete) { echo "MIME 3:"."$mime"."<br>"; if (!empty($this->to)) { $mime .= "To: $this->to\n" ; echo "MIME 4:"."$mime"."<br>"; } if (!empty($this->subject)) { $mime .= "Subject: $this->subject\n" ; echo "MIME 5:"."$mime"."<br>"; } } if (!empty($this->body)) $this->add_attachment($this->body, "", "text/html"); echo "MIME 55:"."$mime"."<br>"; $mime .= "MIME-Version: 1.0\n".$this->build_multipart() ; echo "MIME 6:"."$mime"."<br>"; return $mime; } /* * void send() * Send the mail (last class-function to be called) */ //function send ($message, $data, $fileX, $content_type) function send () { //$bodyY=$this->body ; //echo "BODYY :"."$bodyY"."<br>" ; $mime=$this->get_mail () ; echo "MIME 7:"."$mime"."<br>" ; mail($this->to, $this->subject, "" , $mime) ; //mail($this->to, $this->subject, $this->body, $mime) ; } } ; ////END OF MIME CLASS CODE ///////////////////////////////////////////////////////////////// ?>END CODE: Hi, 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! 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> 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 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'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. 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> 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. 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?. 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 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
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 maxxdim 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. It is not outputting anything after the third echo. This is where it is http://sambender.com/brandon/review.php?subject=Math%20Problems echo "<table border='0'><tr><td><div id='question'><b>Question:</b><br/>$question</div></td></tr>"; echo "<tr><td><div id='answer' style='display:none;'><b>Answer:</b><br/>$answer</div>"; echo "<a href=\"javascript:showdiv('answer')\">Show Answer</a></td></tr>"; echo "<td><tr><a href='submitanswer.php?correct?=yes&correctid=$correctid>I got this correct!</a></tr></td></table>"; It just outputs Code: [Select] <table border='0'><tr><td><div id='question'><b>Question:</b><br/>What is your name?</div></td></tr><tr><td><div id='answer' style='display:none;'><b>Answer:</b><br/>Rooba holabint</div><a href="javascript:showdiv('answer')">Show Answer</a></td></tr><td><tr> Hi, this is my first post but I hope it's fruitful. First, I am running PHP 5.1.6 on my VPS and I am trying to write a Leaderboard script for a game that takes place on my server. The game was not written by me and I know it works perfectly. I have also accessed the database through shell multiple times, so I know that works fine. Here is the code for my leaderboard script: Code: [Select] <html> <title>Middle Cup Leaderboard</title> <body> <?php echo "about to connect\n"; $dbc = mysqli_connect ('localhost','root', 'password', 'shoddybattle') OR die ('sql error:' . mysqli_connect_error() ); echo "Debugging point: connected\n"; //$query = "SELECT estimate FROM users"; //$result = mysqli_query($dbc,$query) or die ('Could not retrieve ratings!'); //echo 'Debugging point: requested\n'; //mysqli_close($dbc); //echo 'Debugging Point: closed\n'; //echo 'Middle Cup Leaderboard Results\n'; //echo $result; ?> </body> </html> Here is the source code of the output when I navigate to it: Code: [Select] <html> <title>Middle Cup Leaderboard</title> <body> about to connect As you can see, it looks as if the program stops indefinitely when I try to connect to the database. Does anyone know what could be wrong with this? Any help would be greatly appreciated! |