PHP - Problem With Php Outputting Information Correctly After Running For A While
I have a script that runs for quite a while (about 700 second per video).
When it is run, it outputs some information for a cURL session. Once the cURL process is initiated php starts downloading a large file to a directory. The file is around 65mb. When the file is finished downloading through curl I have the following code: Code: [Select] echo "Downloaded <br />"; $sw->runDBQuery("UPDATE `videoinfo` SET `videoDownloaded` = '1' WHERE `videoStorageKey`= '".$videostoragekey."' ");The problem I am having is that the script is NOT outputting "Downloaded" in SSH or in the browser BUT the SQL query is being run correctly, and in the background the script moves onto the next file to download (i can see this by monitoring the download directory) but I see no output at all! This leads me to come to two conclusions. Apache is not timing out the request as in SSH, apache is not involved. The browser is not at fault, as I am using Putty. So what could be causing this issue? I am TOTALLY stuck. I cannot work out what the issue could be, it is driving me insance. Any help would be appreciated. Similar TutorialsHello guys i am doing a search function whereby users can check whether a setting is Pass or Fail. After user press the search button, it will return the file which contain the settings the user wants. However i have encountered a problem, currently i am using if statement and && operator to search for file so if the file is missing a string whereby the preg_match function couldn't find it, it will not output the file if i check another setting. Hence i am interested on what other options can i use. Also, Is it possible to use while loop? I tried for awhile and my browser just keeps loading and loading. Thanks for the help! Example: I want to check File 1 for Maximum Password Age settings but it does not contain Service Pack Requirement string... if ((preg_match("/\bService Pack Requirement:(.*)./", $allFiles)) && (preg_match("/\bMaximum Password Age Requirement:(.*)./", $allFiles)) && (preg_match("/\bMinimum Password Length:(.*)./", $allFiles)) && (preg_match("/\bAudit Account Logon Events:(.*)./", $allFiles)) { echo "<a href=\"$file\" target=\"_blank\"> $file </a><br />"; } Hi, I'm having issues trying to add up the totals of each product type in a while loop- I'm sure it's straightforward to fix but for some reason I can't find a way to get it to add up all the totals of the various product types and list them so we have say 5 of product 1, 11 of product 2, 8 of product 3 and so on. So firstly the user searches between two different dates / times to get the orders made during that time period: (I'm using separare date and time fields as the datetime-local input doesn't work in a lot of browsers)
if($_POST['search']) //Now get the orders from the db $getorders = $oc_conn->query("SELECT * FROM oc_order WHERE date_added >= '$datetime1' AND date_added <= '$datetime2' AND order_status_id != 0 ORDER BY order_id DESC"); //Then generate start of a table in HTML, the while loop that follows will populate the rows while ($row = $getorders->fetch_assoc()) { //Get the order data
$firstname = $row["firstname"]; [/PHP] As mentioned in the comment above, what I need is the total $quantity of each $productname, across ALL orders in the time range, so that I can see how many of each product ($productname) were ordered in total. I tried using SUM for quantity in the mySQL, and COUNT for adding up the different product names but for some reason it didn't work. Can someone let me know what I need to do? Thanks :)
I have a Q&A Form/script where registered Users can share there thoughts on 10 Questions. On the backend I have these tables: member, answer, question Thanks to some help last night, I have been able to do a LEFT join and store the above data in a multi-dimensional array which always stoes the 10 Questions, and also any Answers that the User may have responded to. (Questions are optional.) I am having a hell of a time DISPLAYING this multi-dimensional array. The key is that I want my PHP and array to stay at the top of my script and use minimal PHP in my HTML section. Here is how I query the data and build my array... // ******************** // Build Q&A Query. * // ******************** // Build query. $q7 = "SELECT q.id, q.question_no, q.question_text, a.answer_text FROM bio_question AS q LEFT JOIN bio_answer AS a ON q.id=a.question_id AND a.member_id =? ORDER BY q.question_no"; // Prepare statement. $stmt7 = mysqli_prepare($dbc, $q7); // Bind variables to query. mysqli_stmt_bind_param($stmt7, 'i', $memberID); // Execute query. mysqli_stmt_execute($stmt7); // Store results. mysqli_stmt_store_result($stmt7); // Check # of Records Returned. if (mysqli_stmt_num_rows($stmt7) > 0){ // Questions Found. // Bind result-set to variable. mysqli_stmt_bind_result($stmt7, $questionID, $questionNo, $questionText, $answerText); // Populate PHP array with Questions & Answers. $x=1; while (mysqli_stmt_fetch($stmt7)){ $thoughtsArray[$x] = array('questionID' => $questionID, 'questionText' => $questionText, 'answerText' => $answerText); $x=$x+1; } echo '<pre>'; print_r($thoughtsArray); echo '</pre>'; // Close prepared statement. mysqli_stmt_close($stmt7); And in my HTML Form, here is how I am attempting to dynamically build the Q&A section... <form id="changeAnswers" action="" method="post"> <fieldset> <legend>Change Profile Answers</legend> <?php echo '<p>TEST: ' . $thoughtsArray[4]['answerText'] . '</p>'; foreach($thoughtsArray as $questionNo => $qaArray) { echo '<label for="question' . $questionNo . '">' . $questionNo . '.) ' . $qaArray['questionText'] . '</label>'; echo '<textarea id="question' . $questionNo . '" name="thoughtsArray[' . $questionNo . '][\'answerText\']" cols="60" rows="2">' . (isset($questionNo]) ? "htmlentities($thoughtsArray[$questionNo]['answerText'], ENT_QUOTES" : '') . '</textarea>'; } ?> I am able to retrieve and display the Questions from my multi-dimensional array as seen above, however, for the life of me, I cannot get the Input Fields (with any Answers) to work properly. I either get compile errors, or the code runs but my Input Fields are blank even when an Answer should be displayed?! I am hoping this is just a syntax and/or reference error. I'm still new to arrays, so properly retrieving an Answer from a multi-dimensional array is really tricky for me!! So close and yet so far away?! Can someone please help me out?? Thanks, Debbie Ok, I have a graphing class that I built to build simple bar/line graphs for work. I have a side project I'm working on that is a little bigger in terms of data. Usually I do months or weeks. But I have some arrays with about 1000 data sets.
And when I create the image it stops at a certain point and doesn't even draw the X-Axis (One of the last procedures in my code).
And I know there is an issue, because if I Limit the query to 100 results, the graph will come out fine. If I limit it to 200 results the plotted line will show but the X-Axis will be cut of. If I put it to 300 results the plotted line will stop towards 2/3rds the way through the graph.
So I know the code is working when I reduce the results. I check the image info and it's only 3.25kb in size. Not sure what's going on here. I tried googling it but really didn't come up with any solid answers like most google searches.
If anyone has a clue why this is happening, please let me know.
Thanks a lot in advance.
And what's weird is if I add Zebra gridlines to it, on the colored zebra background, I can see a white line that represents the data. It's almost like the ink runs out, lol.
Edited by akphidelt2007, 26 June 2014 - 07:31 PM. 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(); ?> I am pulling an youtube embedded code from a database however when I have the homepage pull it from the database it will not show anything after the video.... EXAMPLE...(this is what it should look like) 1.) Title By: Author Youtube Video Message Posted By: (however this is what it looks like) 1.) Title By: Author Youtube Video *The "message" and "Posted By:" just do not show up* The code is below can someone help me with this problem., it would be greatly appreciated. Code: [Select] <?php //open database $connect = mysql_connect("Database","name","password") or die("Not connected"); mysql_select_db("database") or die("could not log in"); $query = "SELECT * FROM boox ORDER BY date DESC"; $result = mysql_query($query); // Get the page number, if none is set - it is 0 if( isset($_GET['page']) ) { $page =$_GET['page']; } else { $page = 0; } $resultsPerPage = 15; $num = mysql_num_rows($result); // amount of rows $loops = $page*$resultsPerPage; // starting loops at.. while ($loops < $num && $loops < ($page+1)*$resultsPerPage ) { $link = mysql_result($result,$loops,"link"); // get result from the 'link' field in the table $username = mysql_result($result,$loops,"username"); // get result from the 'username' field in the table $messsage = mysql_result($result,$loops,"message"); $author = mysql_result($result,$loops,"author"); $title = mysql_result($result,$loops,"title"); $date = mysql_result($result,$loops,"date"); if ($pagelimit == 0) { $pagelimit == 1; } if ($pagelimit <= 15) // echo stuff here $loopz = $loops + 1; echo "   </br><align='left'><table width='297' height='900' border='1' align='center' bgcolor='#111'> <tr> <td>$loopz.) $title By: $author </br> $link </br> $message </br> Posted By: $username $date </td> </tr> </table></br><br>"; $count++ ; $pagelimit++; $loops++; } if ( $page!=0 ) // Show 'Previous' link { $page--; $prevpage = ($page + 1); echo "<br><br><br><a href='index.php?page=$page'>Previous $prevpage </a>"; $page++; } if ($loops > 5&&($page+1)*$resultPerPage < $num ) // Show 'next' link { $page++; $nextpage = ($page + 1); echo "<a href='index.php?page=$page'> Next $nextpage</a>"; } ?> hi... i have a table ... i add and remove data in the table...when i add new record , information add to center of the table ! whats problem? i want add data in first of table. please guide me.thanks
Hello, I'm trying to echo an additional variable using this: $numincorrect = '<div id="incorrectnum">Sorry, that number was not correct.</div>'; I want to incorperate: $code from require('send.php'); I've tried $numincorrect = '<div id="incorrectnum">Sorry, that number was not "$code".</div>'; However, it literally displays $code on output. Many thanks I have mysql table with Type, Month, Date, and Quantity. I am doing query, and writing to xml which will pass to chart. My error is coming because for each <row> I need to have same number of child tags. For instance, if there are six months represented in first row (<header>), I need to have six <number> tags in all the following rows, even when there may not be any Quantity for that particular month in mysql table. Right now, if a particular Type in my table doesn't show quantity for some months, than I end up with fewer <number> tags. My php is here, and xml structure below: Code: [Select] //start the XML output print "<chart>"; print "<chart_data>"; //output the first row that contains the years print "<row>"; print "<null></null>"; $category = mysql_query ("SELECT prMonth FROM table1 GROUP BY prMonth ORDER BY prDate"); for ( $column=0; $column < mysql_num_rows($category); $column++ ) { print "<header>".mysql_result ( $category, $column, "prMonth")."</header>"; } print "</row>"; //output row 2 to 4. Each row contains a type name and its data (Qty, Prem, Comm ...) $series = mysql_query ("SELECT prType FROM table1 GROUP BY prType ORDER BY prType"); for ( $row=0; $row < mysql_num_rows($series); $row++ ) { print "<row>"; $type = mysql_result ( $series, $row, "prType"); print "<string>$type</string>"; $data = mysql_query ("SELECT SUM(prQty) FROM table1 WHERE prType='$type' GROUP BY prMonth ORDER BY prDate"); for ( $column=0; $column < mysql_num_rows($data); $column++ ) { // Need to do something here to // get number tags to show zero // when there's no data for that // month print "<number>".mysql_result($data,$column)."</number>"; } print "</row>"; } //finish the XML output print "</chart_data>"; print "</chart>"; XML structu Code: [Select] <chart> <chart_data> <row> ----this row will be the head row---- </null> <header>Month name</header> <header>Month name</header> ... </row> <row> ----this row will start body rows---- <string>Type name</string> <number>total quantity for month, for this type</number> <number>total quantity for month, for this type</number> ... </row> ... </chart_data> </chart> Hi there i have a basic query that is simply not outputting, i just dont get it. Im pretty sure the query is sound. If you can spot anything wrong here please let me know. Code: [Select] $colname_RecordSet1 = "-1"; if (isset($_SERVER['MM_Username'])) { $colname_RecordSet1 = (get_magic_quotes_gpc()) ? $_SERVER['MM_Username'] : addslashes($_SERVER['MM_Username']); } mysql_select_db($database_swb, $swb); $query_resultp = sprintf("SELECT PlayerName, PlanetName, Class1, Class2, Class3, Class4 FROM planet WHERE PlayerName = %s", GetSQLValueString($colname_RecordSet1, "text")); $resultp = mysql_query($query_resultp, $swb) or die(mysql_error()); $row_resultp = mysql_fetch_assoc($resultp); $totalRows_resultp = mysql_num_rows($resultp); <?php do { echo 'Class: '; echo $row_resultp['PlanetName']; echo $row_resultp['Class1']; echo $row_resultp['Class2']; echo $row_resultp['Class3']; echo $row_resultp['Class4']; ?> <?php } while ($row_resultp = mysql_fetch_assoc($resultp)); mysql_free_result($resultp); ?> Thanks I'm doing the following query where "ctext" comes from the clues table and "answerid" and "atext" come from the answers table... Code: [Select] $sql = "SELECT * from clues, answers WHERE clues.quizid = '{$_GET['quizid']}' AND answers.quizid = '{$_GET['quizid']}'"; $result = mysql_query($sql, $connection); if (!$result) { die("Database query failed: " . mysql_error()); } else { while ($info=mysql_fetch_array($result)) { echo "<tr><td>" . $info['answerid'] . "</td>"; echo "<td>".$info['ctext']."</td>"; echo "<td>".$info['atext']."</td>"; } echo "</tr>"; } } But when this displays in the browser, it's outputting each result set twice and kinda mixed up. For example, it looks like this... 1 monkey funny 1 cat funny 2 monkey boring 2 cat boring But I want (i.e. was expecting) it to display as... 1 monkey funny 2 cat boring Can anyone tell me why it's showing TWO rows for each and seemingly mixing up the returned results? Ultimate question is this. Do I have to break apart the mysql queries in order to get PHP to display the results how I want? I gotta think there is a way to do just one query and do what I want, but I obviously can't figure it out Hi All, I'm working on an X-Cart site. Looking through the pages, any page with an apostrophe in the content is being loaded as an � instead. The sites' char set is UTF-8. Changing it to ISO then creates an issue in itself with bulleted lists. Just wondering if anyone has had the problem in the past and if they have solved it? Any help appreciated. Cheers On my website, I have Sticky Forms that use the following style code... <input id="firstName" name="firstName" type="text" maxlength="30" value="<?php if(isset($firstName)){echo htmlspecialchars($firstName, ENT_QUOTES);} ?>" /><!-- Sticky Field --> Do I need to use htmlspecialchars($firstName, ENT_QUOTES); anytime I output data to the screen?? For example, in this code do I need to wrap $username?? echo ' <div class="userInfo"> <a href="#" class="username"> <strong>' . $username . '</strong> </a>'; Debbie I have converted xml into an array with no problems, however I'm having difficulty outputting the various attributes. Here is a sample: Code: [Select] [0] => Array ( [@attributes] => Array ( [YourId] => 1082-1 [Name] => Woodwards Metals [Description] => ) ) The bit that is confusing me is the @attributes part. How would I output the 'Name' element for example? Hi
I have a self calling script which does the following:
Stage 1: First run, it detects that $_POST is empty, and so displays a chunk of html which prompts for a password.
Stage 2: When resubmitted, it detects $_POST and displays another chunk of html which prompts the user for some values
Stage 3; When resubmitted the second time, $_POST is detected, along with the user values and some php is executed and a menu displayed.
So, question is this, what is the best method to output the html at stage 1 and stage 2?
I have tried using echo statements and wrapping each chunk in a function = messy.
I have tried using HEREDOCS (<<<VARNAME), better but ties my HTML to my script which is a pain
I am thinking to use file_get_contents("../html/chunk1.htm") this seems quite elegant and allows me to get someone else on our team to design the HTML keeping it out of my script
Thoughts and suggestions?
Thanks as ever
p.s. who pays for this site, are donation accepted?
What is the proper way to output the contents of a class? (We will assume that Getters and Setters are evil...) Let's say I have the following class... class FormHandler2 { // Define Variables. private $myFormArray; // Constructor. public function __construct($param){ $this->myFormArray = $param; } } ...and I want to be able to output its contents either via a variable dump OR by printing something to the screen. How would I do that? TomTees At the moment I have multiple pages with different HTML tables coded in (some have 5 columns and some 6 etc) and PHP echoing out data to populate from the database. The table in each page holds different data. It looks messy to me to code a different table for every page so I'm wondering if it's possible to create a function to do this? The function would have to print tables with different amounts of columns and echo out different data depending on what the page is along with table headers etc. How would I go about that? Hello guys. I am facing a little problem on my website when I am trying to output the data from the database in the form of a table. If you go to http://sigmalogistix.com/track-trace/ and enter any on of the following B/L No's: 123456789 987651234 543216789 You can see that the table is being created but the data is not being shown to the user. If I switch back to the old code in which there was no table, then the data is being shown to the user upon entering the B/L No. Please help me guys. Attached below are the codes which I have inside the function.inc.php file and the index.php file. function.inc.php Code: [Select] <?php include 'db.inc.php'; function search_results($keywords) { $returned_results = array(); $where = ""; $keywords = preg_split('/[\s]+/', $keywords); $total_keywords = count($keywords); foreach($keywords as $key=>$keyword){ $where .= "`keywords` LIKE '%$keyword%'"; if ($key != ($total_keywords - 1)) { $where .= " AND "; } } $results = "SELECT `Bill_No`, `Origin_City`, `Origin_Country`, `Destination_City`, `Destination_Country`, `Status`, `Current_Location` FROM `billoflading` WHERE $where"; $results_num = ($results = mysql_query($results)) ? mysql_num_rows($results) : 0; if ($results_num === 0) { return false; } else { while ($results_row = mysql_fetch_assoc($results)) { $returned_results[] = array ( 'Bill_No' => $results_row['Bill_No'], 'Origin_City' => $results_row['Origin_City'], 'Origin_Country' => $results_row['Origin_Country'], 'Destination_City' => $results_row['Destination_City'], 'Destination_Country' => $results_row['Destination_Country'], 'Status' => $results_row['Status'], 'Current_Location' => $results_row['Current_Location'] ); } return $returned_results; } } ?> index.php Code: [Select] <?php include 'func.inc.php'; ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>search</title> </head> <body> <form action="" method="POST"> <p> <input type="text" name="keywords" size="17" maxlength="9" value="Enter B/L No." onfocus="if(this.value == 'Enter B/L No.'){this.value = '';}" /> <input type="submit" class="formbutton" value="Track" /> </p> </form> <?php if (isset($_POST['keywords'])) { $suffix = ""; $keywords = mysql_real_escape_string(htmlentities(trim($_POST['keywords']))); $errors = array(); if (empty($keywords)) { $errors[] = ''; } else if (strlen($keywords)<9) { $errors[] = '<br><strong>Your Bill of Lading Number must contain 9-digits.</strong>'; } else if (search_results($keywords) === false) { $errors[] = '<br><strong>Please enter a valid Bill of Lading Number.</strong>'; } if (empty($errors)) { $results = search_results($keywords); $results_num = count($results); $suffix = ($results_num !=1) ? 's' : ''; foreach($results as $result) { echo '<br><table> <thead> <tr> <th><strong>B/L No.</strong></th> <th><strong>Origin City</strong></th> <th><strong>Origin Country</strong></th> <th><strong>Destination City</strong></th> <th><strong>Destination Country</strong></th> <th><strong>Status</strong></th> <th><strong>Current Location</strong></th> </tr> </thead> <tbody> <?php while ($row = mysql_fetch_assoc($results) { ?> <tr> <td><?php echo $row["Bill_No"]; ?></td> <td><?php echo $row["Origin_City"]; ?></td> <td><?php echo $row["Origin_Country"]; ?></td> <td><?php echo $row["Destination_City"]; ?></td> <td><?php echo $row["Destination_Country"]; ?></td> <td><?php echo $row["Status"]; ?></td> <td><?php echo $row["Current_Location"]; ?></td> </tr> <?php } ?> </tbody> </table>'; } } else { foreach($errors as $error) { echo $error, '</br>'; } } } ?> </body> </html> Hi guys, I am very simply inserting text into a table with php and mysql, and outputting it, it all works fine but when I use paragraphs when inserting it, and then try to ouput it, all the paragraphs are gone and it looks like one big block of text, I suppose the way to go around this is to use <br> instead of just enters as it probably doesnt read this, but is it possible to make this text area do read and insert <br>'s where people use enter to make paragraphs? Much help appreciated, I realize this must be a very beginner question but I am not really sure how to word this so I wasn't sure on specific search on this. The code below is in a PHP file, but is really HTML with nested PHP. <img src="<?php echo WEB_ROOT; ?>images/BeachSunset.jpg" width="200" alt="Pictu Beach Sunset." title="Pictu Beach Sunset." /> I want to put it in a MySQL record and output it using PHP. So how do I re-write this code so that it can be displayed with the same end effect using a PHP Echo statement?? (I seem to be having trouble figuring things out with MySQL in the way?! Thanks, Debbie |