Jump to content

myrddinwylt

Members
  • Posts

    84
  • Joined

  • Last visited

    Never

Everything posted by myrddinwylt

  1. I would check to ensure that caching is disabled in the server such as APC, Zend, etc. Also, if you are using a template system such as Smarty, it could produce odd results if not used correctly. As the Admin said, the code you quoted could not produce the message that you are seeing, so it must either be coming from another script, different code, or something that has been cached somewhere from another piece of code.
  2. Hello, The datetime field stores the date and time as a string in the format "Y-m-d h:i:s A". As this is a string format, you can not format the date string without converting it back into a timestamp variable type. Try the following $post_date = strtotime($row3['post_time']);
  3. Nice, Didn't think it was that simple It appears that the syntax is the same as in most other languages that incorporate these commands. As for using "break;" inside a loop, I have never really thought about that as I thought it was something exclusive to "switch" / "case" scenarios. Thank you (surprisingly, this has been bugging me for several years XD)
  4. If you are doing what I do sometimes: Posting to another page then forwarding the user off that page to another page on completion Then you can use the following code for a redirect in PHP header('location: /index.php'); This can only be used if nothing has been printed to the page. If something has been printed to the page, simple echo out some javascript for the redirect. $script = '<script type="text/javascript">location.replace(\'/index.php\');</script>'; echo $script;
  5. @ChemicalBliss: Yes, that is a typo in my post here only. The actual code contains "==" for the comparison. @harristweed: I do it this way as it is getting a value set from the database, which could be multiple blank spaces, or a null, but ideally I wish it to always be numeric. The code where the variable is being set is as follows: function dumpsql($daydownloaded) { $con = mysql_connect($this->server,$this->username,$this->password) or die(mysql_error()); $sql = ''; set_time_limit(3600); if ($con !== false){ mysql_select_db($this->database); $query="SELECT * FROM `" . $this->database_temp . "`.`" . substr($daydownloaded,0,-3) . "` ORDER BY `Started` ASC;"; $result=mysql_query($query,$con) or die(mysql_error()); $num=mysql_numrows($result); $i=0; if ($num > $i) { $sql[] = "CREATE TABLE IF NOT EXISTS `" . $this->database . "`.`" . substr($daydownloaded,0,-3) . "` (`uniqueid` int(11) NOT NULL AUTO_INCREMENT, `Caller` varchar(255) DEFAULT NULL, `Started` datetime DEFAULT NULL, `Dialed` varchar(255) DEFAULT NULL, `DurationSec` int(11) DEFAULT NULL, `DurationMin` int(11) DEFAULT NULL, `Cost` double DEFAULT NULL, `Location` varchar(60) DEFAULT NULL, `Switch` varchar(15) DEFAULT NULL, PRIMARY KEY (`uniqueid`)) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;"; $sql[] = "DELETE FROM `" . $this->database . "`.`" . substr($daydownloaded,0,-3) . "` WHERE `Started` LIKE '" . $daydownloaded . "%';"; } while ($i < $num) { $caller = mysql_result($result,$i,"Caller"); $started = mysql_result($result,$i,"Started"); $dialed = mysql_result($result,$i,"Dialed"); $durationsec = mysql_result($result,$i,"DurationSec"); $durationmin = mysql_result($result,$i,"DurationMin"); $cost = mysql_result($result,$i,"Cost"); if(trim($cost . "") == "") { $cost = "0"; } $location = mysql_result($result,$i,"Location"); $switch = mysql_result($result,$i,"Switch"); $sql[] = "INSERT INTO `" . $this->database . "`.`" . substr($daydownloaded,0,-3) . "` VALUES(null, '" . $caller . "', '" . $started . "', '" . $dialed . "', " . $durationsec . ", " . $durationmin . ", " . $cost . ",'" . $location . "','" . $switch . "');"; $i++; } mysql_close($con); } unset($con, $caller, $started, $dialed, $durationsec, $durationmin, $cost, $location, $switch); return $sql; } This error occurs only when the condition is met.
  6. The equivalent selects for the above updates entail various records. They are indexed on 2 columns. UniqueID = This column is of type INT AUTO_INCREMENT INDEX (primary key) OrigDialedDigits = The column that is being compared with the "LIKE" statements. There is no other way to do this comparison, and must be done in descending order based on the length of the CODE.
  7. Figured out the problem Apparently PHP 5.3.2 isn't smart enough to resolve "localhost" as "127.0.0.1" ... I put the IP in, and it works. I tested this on an older version of PHP on the same machine, and the flaw was not present before 5.3.x.
  8. Here is a question bugging me for a long time. In many languages, C, Delphi, VB, ASP, even ASM, allow for some internal call which allows you to tell the program to skip code and go to a particular pointer, then continue from there. What is the equivalent to the following in PHP y = 2 x = 4 startover: do z = y * x if z = 396 then goto finalcall if y > 200 then exit do loop goto codeexit finalcall: print y y = y + 1 goto startover codeexit: The above code contains a couple of examples where "goto" comes in handy. Inside the loop, it also contains a condition on which the loop would exit. I understand that particular condition could be included in the loop initialization, however, I am only displaying the logic question in it's simplest forms. In the real world, the logic required to exit the loop would be much more complex, and perhaps entailing many different conditions to exit the loop based on variables that are set or a particular functions result using values passed as designed in the loop code itself. In PHP, I have found no way to exit a loop without having the conditions pre-defined in loop initialization (and the loop will never exit until those conditions are met), nor have i found a method to tell the program ... goto XYZ pointer, and start running the code from there (aka... goto startover is a good example of this). Does anyone have an idea about the equivalent commands and pointers in PHP, or is this too, something left out. ( 8 million ways to connect to MySQL, and no ways to do this ??? )
  9. Here is a bizzare error..... if(trim($cost . "") == "") { $cost = "0"; } Sometimes returns the following error in the browser : WTF!! Fatal error: Can't use function return value in write context in C:\server\websites\127.0.0.1\htdocs-ssl\cdrdownloader\mysql.class.php on line 95
  10. Thank you guys for the responses. I guess based on this information, PHP does not have any garbage cleanup, so simply unsetting an object, or setting the object to null doesn't free it's memory space. Further, return variables also are not automatically cleaned such as the following: function somefunction() { $var1 = "hello world"; return $var1; } $var2 = somefunction(); The above code would end up using double the memory space, as the function "somefunction()" contains a variable which can not be "unset()", etc, as it must return the value as the functions result. Upon returning that value, $var1 is not cleaned up, and permanently consuming memory. Then $var2 which is active variable that stores the result of "somefunction()", is further consuming at least the memory space of the return value -- in this case "hello world". This to me, is a severe design flaw with the language itself, and must be addressed. Garbage cleanup is necessary, and should not be left up to the OS. So either this language is fundamentally flawed at it's source, or the information that is available (through responses here, and on php.net itself), is not accurate. Personally, if my server has 32 GB of memory, I do not wish to run out of memory simply because I looped through 500,000 customers (something even Visual Basic can handle the garbage cleanup for --- or... comparability: ASP / ASP.NET) .
  11. Thank you for the response joel24. Just a couple quick questions about this. Will "unset()" work with objects as well as variables? Does "unset()" completly release the memory that object used? (meaning, if you look in taskmanager, will you see the actual memory in use of PHP drop after this function is called -- proving the memory has in fact been completely freed) Will "unset()" work recursively? (aka .... ) $x = 0; while($x < 3) { $myobj[] = new object(); $x++; } unset($myobj);
  12. Hello, I have some blocks of code which loop through a database of customers, then for each customer, their phone numbers, and services, and generates a PDF file using TCPDF. The code is working and functional and generates the proper output. Inside the each loop, when finished with variables and objects, I cleanup to the best of my ability by setting them to "null" --- for example: $obj = null; Prior to that, I also close any open database connections. "mysql_free_result($result);" doesn't work at all and produces an error, so I do the following: $result = null; mysql_close($cn); $cn = null; After each PDF is output, I set the object to null as well, and well... you get the idea, after everything, I incorporate cleanup (always a good habit). Now the problem. After around 400-500 records, php runs into a memory exhausted limit issue. If I increase the limit, I can get a few more invoices created, but really, php should be cleaning up this crap. How can I best ensure inside the same loop, that cleanup occurs on the variables after closing objects / variables, and setting them to null ---- or is this an inherant flaw in php where garbage cleanup simply does not exist ?. I do not wish to output anything to the screen during this process. The timeout is set for long enough to generate the PDF's, and the entire process shouldn't take longer than around 10-15 minutes. Thanks in advance.
  13. Hello, Kind of a bizzare problem. From within PHP 5.3.2, if i try mysql_connect("localhost","root","") or die(mysql_error()); It results in the following message: Warning: mysql_connect() [function.mysql-connect]: [2002] A connection attempt failed because the connected party did not (trying to connect via tcp://localhost:3306) in C:\server\websites\127.0.0.1\htdocs-ssl\cdrdownloader\index.php on line 23 Warning: mysql_connect() [function.mysql-connect]: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. in C:\server\websites\127.0.0.1\htdocs-ssl\cdrdownloader\index.php on line 23 Fatal error: Maximum execution time of 30 seconds exceeded in C:\server\websites\127.0.0.1\htdocs-ssl\cdrdownloader\index.php on line 23 If I try to connect on the same machine, but instead of using PHP, I use the command prompt (or quite literally connect in any other way except PHP), I connect with no problems: C:\server\bin>mysql -P 3306 -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 17 Server version: 5.1.30-community MySQL Community Server (GPL) Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> exit Bye The "libmysql.dll" located in the PHP folder, is the same version for the server. What else am I missing ? This only became a problem after updating (with a lot of effort), to PHP 5.3.2. I kind of need to connect to MySQL using PHP Thanks in advance.
  14. Woohoo !! I got it. The problem is when the program is puking that crap html, and there is no value in that column, instead of putting <span></span>, it puts a <br> in between the <td></td>. I modified the code, and came up with this which is working 100% under anything I throw at it. $test = file_get_contents('omnipoo2.txt'); preg_match_all('~Select Row</label>.*?>(.*?)</tr>~', $test, $out); foreach($out[1] as $matchedrow) { $matchedrow = str_replace('<br>','<span> </span>',$matchedrow); preg_match_all('~<span[^>]*>([^<]*)</span>~', $matchedrow, $out2); print_r($out2); } Thanks for the help
  15. I think I might have found a quick solution to this, unfortunately, my knowledge of regex forces me to do this in stages. First RegEX: Break out the rows Select Row</label>.*?>(.*?)</tr> Then a PHP loop through those results executing a second RegEX which returns the values contained in <span> <span[^>]*>([^<]*)</span> Please let me know what you think of this solution, or if you have any way to improve it so it could be done in a single statement? Thanks.
  16. sasa, All I can say is WOW !! ... That is exactly what I was looking for. It worked for page 1, but for some reason it's not working for other pages. Would you mind if I uploaded a couple of pages, so you could tweak the code a bit. I know the html is very poo poo messy, but it would probably help fine tune where changes in the table are occuring. I am thinking it has something to do with one of the parameters looking for specific class="" ... and even though Omni is automaticaly spewing this poo, I think the style names may be inconsistent. In the regex you put, it looks like you are looking for specific styles which may be why it's skipping on different pages. Am I correct that this is the chunk of code you are first splitting out, then the further portions of regex are processing it for the other information ? Select Row</label></td><td class="x1l x4x"><span class="x6">18788</span></td><td class="x1l x4x"><span class="x4">WINDSOR MONEYSAVER</span></td><td class="x1l x4x"><span class="x4">Terminated</span></td><td class="x1l x4x"><span class="x4">11/29/05</span></td><td class="x1l x4x"><span class="x4">03/31/07</span></td><td class="x1l x4x"><br></td><td class="x1l x4x"><br></td><td class="x1l x4x"><span class="x6">-3737.77</span></td><td class="x1l x4x"><span class="x6">0</span></td></tr><tr><td class="x1p x4x"><input id="M__Ide" title="Select Row" value="1" name="viewAccountsTable:selected" type="radio"><label for="M__Ide" class="x38">Select Row</label></td><td class="x1l x4x"><span class="x6">14532</span></td><td class="x1l x4x"><span class="x4">PARMI SAHOTA</span></td><td class="x1l x4x"><span class="x4">Active</span></td><td class="x1l x4x"><span class="x4">09/25/05</span></td><td class="x1l x4x"><br></td><td class="x1l x4x"><span class="x4">PARMI SAHOTA</span></td><td class="x1l x4x"><span class="x4">JJOHNSON</span></td><td class="x1l x4x"><span class="x6">-425.14</span></td><td class="x1l x4x"><span class="x6">0</span></td></tr><tr><td class="x1p x4x"><input id="M__Idf" title="Select Row" value="2" name="viewAccountsTable:selected" type="radio"><label for="M__Idf" class="x38">Select Row</label></td><td class="x1l x4x"><span class="x6">18433</span></td><td class="x1l x4x"><span class="x4">BERT VIEIRA</span></td><td class="x1l x4x"><span class="x4">Active</span></td><td class="x1l x4x"><span class="x4">11/01/05</span></td><td class="x1l x4x"><br></td><td class="x1l x4x"><br></td><td class="x1l x4x"><br></td><td class="x1l x4x"><span class="x6">-309.36</span></td><td class="x1l x4x"><span class="x6">0</span></td></tr><tr><td class="x1p x4x"><input id="M__Idg" title="Select Row" value="3" name="viewAccountsTable:selected" type="radio"><label for="M__Idg" class="x38">Select Row</label></td><td class="x1l x4x"><span class="x6">19808</span></td><td class="x1l x4x"><span class="x4">*PHILAMENA DAVENPORT</span></td><td class="x1l x4x"><span class="x4">Active</span></td><td class="x1l x4x"><span class="x4">03/11/96</span></td><td class="x1l x4x"><br></td><td class="x1l x4x"><br></td><td class="x1l x4x"><span class="x4">PRE-EXISTING</span></td><td class="x1l x4x"><span class="x6">-292.8</span></td><td class="x1l x4x"><span class="x6">0</span></td></tr><tr><td class="x1p x4x"><input id="M__Idh" title="Select Row" value="4" name="viewAccountsTable:selected" type="radio"><label for="M__Idh" class="x38">Select Row</label></td><td class="x1l x4x"><span class="x6">13745</span></td><td class="x1l x4x"><span class="x4">PINE RIDGE DENTAL CENTRE</span></td><td class="x1l x4x"><span class="x4">Active</span></td><td class="x1l x4x"><span class="x4">10/01/05</span></td><td class="x1l x4x"><br></td><td class="x1l x4x"><br></td><td class="x1l x4x"><br></td><td class="x1l x4x"><span class="x6">-281.9</span></td><td class="x1l x4x"><span class="x6">0</span></td></tr><tr><td class="x1p x4x"><input id="M__Idi" title="Select Row" value="5" name="viewAccountsTable:selected" type="radio"><label for="M__Idi" class="x38">Select Row</label></td><td class="x1l x4x"><span class="x6">11649</span></td><td class="x1l x4x"><span class="x4">ERLA HANCOCK</span></td><td class="x1l x4x"><span class="x4">Active</span></td><td class="x1l x4x"><span class="x4">07/01/05</span></td><td class="x1l x4x"><br></td><td class="x1l x4x"><br></td><td class="x1l x4x"><span class="x4">BILL VIDA</span></td><td class="x1l x4x"><span class="x6">-261.21</span></td><td class="x1l x4x"><span class="x6">0</span></td></tr><tr><td class="x1p x4x"><input id="M__Idj" title="Select Row" value="6" name="viewAccountsTable:selected" type="radio"><label for="M__Idj" class="x38">Select Row</label></td><td class="x1l x4x"><span class="x6">17402</span></td><td class="x1l x4x"><span class="x4">SPARTAN NUTRITION also 17403</span></td><td class="x1l x4x"><span class="x4">Terminated</span></td><td class="x1l x4x"><span class="x4">09/25/05</span></td><td class="x1l x4x"><span class="x4">02/28/06</span></td><td class="x1l x4x"><br></td><td class="x1l x4x"><span class="x4">JJOHNSON</span></td><td class="x1l x4x"><span class="x6">-242.51</span></td><td class="x1l x4x"><span class="x6">0</span></td></tr><tr><td class="x1p x4x"><input id="M__Idk" title="Select Row" value="7" name="viewAccountsTable:selected" type="radio"><label for="M__Idk" class="x38">Select Row</label></td><td class="x1l x4x"><span class="x6">14086</span></td><td class="x1l x4x"><span class="x4">VALTER VIVEIROS</span></td><td class="x1l x4x"><span class="x4">Active</span></td><td class="x1l x4x"><span class="x4">09/25/05</span></td><td class="x1l x4x"><br></td><td class="x1l x4x"><br></td><td class="x1l x4x"><span class="x4">PRE-EXISTING</span></td><td class="x1l x4x"><span class="x6">-229.05</span></td><td class="x1l x4x"><span class="x6">0</span></td></tr><tr><td class="x1p x4x"><input id="M__Idl" title="Select Row" value="8" name="viewAccountsTable:selected" type="radio"><label for="M__Idl" class="x38">Select Row</label></td><td class="x1l x4x"><span class="x6">18569</span></td><td class="x1l x4x"><span class="x4">SHERRI BURGENER</span></td><td class="x1l x4x"><span class="x4">Collections</span></td><td class="x1l x4x"><span class="x4">11/01/05</span></td><td class="x1l x4x"><span class="x4">06/30/06</span></td><td class="x1l x4x"><br></td><td class="x1l x4x"><br></td><td class="x1l x4x"><span class="x6">-165</span></td><td class="x1l x4x"><span class="x6">0</span></td></tr><tr><td class="x1p x4x"><input id="M__Idm" title="Select Row" value="9" name="viewAccountsTable:selected" type="radio"><label for="M__Idm" class="x38">Select Row</label></td><td class="x1l x4x"><span class="x6">15788</span></td><td class="x1l x4x"><span class="x4">DAN FLORESCU</span></td><td class="x1l x4x"><span class="x4">Collections</span></td><td class="x1l x4x"><span class="x4">09/25/05</span></td><td class="x1l x4x"><span class="x4">08/31/06</span></td><td class="x1l x4x"><br></td><td class="x1l x4x"><span class="x4">ABUKAR NUR</span></td><td class="x1l x4x"><span class="x6">-161.2</span></td><td class="x1l x4x"><span class="x6">25.88</span></td></tr></table> Perhaps the regex could be modified a bit so it doesn't matter what the length is inside class... So perhaps something like class="%" ... where % is whatever the regex condition is that allows for a string containing any characters of any length. Just some thoughts on this mess :/ Again, thank you
  17. Hello, Your question isn't really PHP related then, it has to do with the correct syntax for the MAILTO: link. In either case, to insert a new line, using a MAILTO link, you would use the following: %0A For more information about the MAILTO link syntax, please see This Page . It is actually a link located on the Institute of National Agriculture --- dunno why.... but it's very technical FAQ on the syntax and is not related to the content of their site in any way. In your message above, you have </ br>, but in your code you are searching for <br />. Since I am not the greatest with RegEX, here is a manual method of assuring that characters get replaced properly. $mailreplacebr = str_replace("<br />","%0D%0A", $dbmsg); $mailreplacebr = str_replace("<br/>","%0D%0A", $mailreplacebr); $mailreplacebr = str_replace("<br>","%0D%0A", $mailreplacebr); $mailreplacebr = str_replace("</ br>","%0D%0A", $mailreplacebr); $mailreplacebr = str_replace("</br>","%0D%0A", $mailreplacebr); $mailreplacebr = str_replace("\r\n","%0D%0A", $mailreplacebr); $mailreplacebr = str_replace("\n","%0D%0A", $mailreplacebr); For information on how to send mail using PHP, I am reposting the links I did above because there is an error in the last 2 links. PHP4: PHPMailer 2.0.4 PHP5: PHPMailer 5.1 For examples and information about the author for this free module, visit Worx International Inc.
  18. Assuming you are going to insert back into the same table, and the field "ID" is set as Primary Index, AutoIncrement, you can do the following INSERT INTO 'food' (SELECT null as id, food_id, 'oz' as weight FROM `food` WHERE `weight` NOT LIKE '%oz%'); Or if you are wanting to modify those records, and not insert new ones, then UPDATE food SET weight = 'oz' WHERE `weight` NOT LIKE '%oz%');
  19. How do I flag my question as Solved once I have received a satisfactory answer ? I am using firefox, and do not see an option to do this.
  20. If you wish to make it a bit easier to read, try the following <?php session_start(); include('db.php'); $father_query = "SELECT * from main where gender='1' ORDER BY lastname, firstname"; $father_result = mysql_query($father_query); $i=1; $options = null; while($father_row = mysql_fetch_array($father_result)){ $options .= '<option value="' . $father_row['id'] . '">' . $father_row['lastname'] . ',' . $father_row['firstname'] . '</option>'; $i++; } if($options == null) { $options = '<option value="0"> --- NO OPTIONS AVAILABLE --- </option>'; } else { $options = '<option value="0">Unknown</option>' . $options; } echo '<select>' . $options . '</select>'; ?>
  21. To ensure the SQL string is properly encapsulated in quotes where necessary and to avoid any post confusion, I would personally do it this way $sql = "INSERT INTO Customers (CustomerID, EmailAddress, Postalcode, Phonenumber, Forename, Surname, Address) VALUES ('" . $_POST['CustomerID'] . "', '" . $_POST['EmailAddress'] . "', '" . $_POST['Postalcode'] . "', '" . $_POST['Phonenumber'] . "', '" . $_POST['Forename'] . "', '" . $_POST['Surname'] . "', '" . $_POST['Address'] . "')"; So if the Values were as follows: CustomerID: 10976 EmailAddress: bob@bob.com Postalcode: L1H1A4 PhoneNumber: 4164770101 Forename: Bob Surname: Smith Address: 123 Front St, Toronto The generated MySQL would be: INSERT INTO Customers (CustomerID, EmailAddress, Postalcode, Phonenumber, Forename, Surname, Address) VALUES ('10976', 'bob@bob.com', '4164770101', 'Bob', 'Smith', '123 Front St, Toronto'); You may want to make some adjustments. For example, if the CustomerID field is an INT value, then you can safely add that field without the single quotations '. Also, you may want to mysql_escape_string or whatever the function is called to add \ to each post value prior to inserting. So if you had someone with the name Mc'Leans for example, the resulting insert for that field would be 'Mc\'Leans'
  22. DirtySnipe, I am not on these forums to make money. I am here to contribute back to the community the same support that I have received, and would like to receive myself. By "intense", I didn't imply that it would require a complete rewrite, as it can be done with what you have provided. Probably with very little modification, but would take some time to study how the information is being loaded, what fields are available from the database (aka, can we display 7 days, and filter each into it's own group ?). The drawing of the HTML using php doesn't appear that it would pose much of a barrier. Just seems like I am missing something so I can see the whole picture. I would definitely be happy to provide further assistance. Perhaps you have a "test" environment that I could experiment with to get this project fixed up for you, or maybe wait and see what other people on the forums here have to say that may be able to resolve the problem faster. If you wish, you can send me a PM for more information.
  23. Use this library for sending your e-mail instead of the internal "mail()" function. You havn't stated what method you are using to send e-mail, but regardless, this is the best solution for sending mail as it supports pretty much every type of connection method, and it can authenticate (aka, just pass it the same credentials you would pass Outlook, etc). PHP Mailer 2.0.4 for PHP4 PHPMailer 5.1 for PHP5[/code] For examples and information about the author for this free module, visit Worx International Inc.
×
×
  • 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.