Jump to content

ManiacDan

Staff Alumni
  • Posts

    2,604
  • Joined

  • Last visited

  • Days Won

    10

Everything posted by ManiacDan

  1. Nested loops are almost always a bad idea. What you should do is pre-process your query data so that you get a nicely formatted "lookup array," where the key to the array is the product ID you're getting from this $_POST['check'] array, and the value of the array is itself an array that features the data you need. Your echo would then look like: echo $data[$product]['price'] . " " . $data[$product]['currency'] . " for " . $product . "<br />"; -Dan
  2. Show the results for SHOW CREATE TABLE on this table. Did you make sure you only had ONE database and database server? You're not inserting into test and checking production or anything like that? --Dan
  3. He means to paste it inside [ code ] tags. Also, are you sure you're in the right database on the right server? Your PHPMyAdmin instance is probably running on the local MySQl server, the PHP script could be connecting to another server entirely. -Dan
  4. You have to use javascript to do calculations without page refreshes. javascript is a language that exists inside your HTML document and is executed on the client's computer, not on your server. -Dan
  5. I see probably 1,500 lines of code without a single error reporting function. How have you been doing this for "so[ox5] long" without using mysql_error() ? Have you tried that? Have you turned error_reporting all the way up? Have you tried putting debug echoes in this script to see what the values of everything are? ereg is deprecated and should not be used. Since you don't know that, I'm assuming your errors are set to a level that hides the deprecation warning. Set error_reporting(E_ALL) at the top of your script, and make use of mysql_error(). -Dan
  6. If the printer is hooked to your SERVER, you should be able to spool directly to print jobs on the command line without using socket connections. If the printer is hooked to your CLIENT (the computer you're using to view these reports), you can invoke the print dialog in javascript when you need it, then just click "ok" and it will print. -Dan
  7. You can make a column in MySQL that will default to the insert time for that record, it should be a pretty easy change for you. -Dan
  8. Yes, your items should have timestamps associated with them. Just about every database table should have a create_date column, you'll find some use for it. -Dan
  9. Why are you even doing it like this? There's usually no reason to store repeating data in large numbers of columns like this. That's why databases have ROWS.
  10. You could avoid this entire problem by using the proper format for date() on the first page that you set this variable on. There's no reason to set $_SESSION['date'] to a formatted string you have no intention of using, only to convert it back to a timestamp and then into another formatted string later on. -Dan
  11. <?php echo date('F j, Y', strtotime($_SESSION['date']));
  12. Ok, a number of things: 1) You could very well use the PHP variable syntax and run it back through the PHP parser to let PHP handle your interpolation, but that's dangerous and unnecessary for such a simplistic task. 2) You're honestly saying that you will not know ahead of time what these content blocks will be named? They could be anything? How are you planning on generating code if someone drops in a content block like {block type="my_new_block" name="The Page"} ? What will your code do? Maybe that's the question we should have asked from the beginning. How will you be filling in custom block names? If you have a database table full of content block names...we're back to my str_replace suggestion. 3) Just because it's regex doesn't mean it's more complicated or more correct. Regex is a last resort. It's slow, cumbersome, confusing, and prone to errors. XML parsing would work better if this is pure namespaced HTML (which it appears to be) and str_replace will be the absolute fastest route. -Dan
  13. Why do this at all? Why not simply use PHP variable names? <div id="wrapper"> {$leftSideBlock} {$contentBlock} {$rightSideBlock} </div> You will have a fixed set of content blocks. str_replace will do this for you easily. -Dan
  14. It's sloppy to use two, but I'm going to lunch and can't be bothered. I'm pinging requinix though, it's like the bat signal, only for regex: $string = '{block type="left_side" name="Left Side"}'; preg_match('/\{block ([^\}]+)\}/', $string, $foo); preg_match_all('/([^=]+)="([^"]+)"\s*/', $foo[1], $bar); foreach ( $bar[1] as $k => $v ) { echo "{$v} = {$bar[2][$k]} <br />\n"; } -Dan
  15. What have you tried so far? This is relatively simple to parse just this tag. Parsing multiple tags in the same document which may or may not be nested or malformed is significantly harder, to the point where regex might not be able to do it. -Dan
  16. the preg_replace method is very slow and processor intensive, you probably just want a combination of strlen and str_repeat. That is, only if cssfreakie's solution isn't what you actually need. -Dan
  17. This is usually done with regular expressions, I imagine. -Dan
  18. (.*) <-- that selects as many things as it can, as long as the whole expression is still valid. Regular expressions are greedy, and will match things as wide as it can. You must use the "ungreedy" modifier to prevent this. Change (.*) to (.*?) -Dan
  19. There are special characters in regular expressions too. These characters must be escaped with a back slash: /?*$^. -Dan
  20. Look at your code. See how the coloring is wrong? That's because your string is wrong. If you use single-quotes ( ' ) to enclose a string, any single quotes inside the string must be escaped: ( \' ) -Dan
  21. Ok...do that. Which part do you not know how to do? If you don't know any PHP, you'll need a "learn php" book. I personally recommend "Web Database Applications with PHP & MySQL" from O'Reilly press. -Dan
  22. There is no scrolling code in that page you provided. The function anythingslider appears to be the culprit, but since I don't have IE and I don't feel like digging through wordpress javascript, that's as far as I'm going to go. The two most common ways to scroll the page on click are the scrollTo method or an anchor tag containing a "#" in it. -Dan
  23. I've merged the three threads on this topic into one, and left it in the JS forum. -Dan
  24. You didn't say you already had a loop that was generating these arrays. $newArray = array(); while($row = mysql_fetch_array($run_mysql_query)){; //this is wrong, no semicolon here. $models = $row['text_value']; $attribute1 = $row['attribute1']; $attribute2 = $row['attribute2']; $array = explode(',', $models); $newArray = array_merge($newArray, $array); foreach($array as &$value) { $value = $row['varchar_value'] . " - " . $value . " - " . $attribute1 . " - " . $attribute2; } } print_r($newArray);
  25. ...and this is why we recommend not storing HTML in a database. You run into this very problem. What you might want to do is: strip the HTML find the 49th and 50th word. use a regular expression to trim the original article down to the content up to those two words (which may be separated by one or more HTML tags) Print the resulting string, with any weird tags removed. -Dan
×
×
  • 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.