Jump to content

btherl

Staff Alumni
  • Posts

    3,893
  • Joined

  • Last visited

Everything posted by btherl

  1. I can see the earlier fields when viewing with IE 8, both with and without compatibility view. Maybe the styling is affecting it? Also which version of IE are you testing with?
  2. I've never heard of escape_data(), but judging by a google search, it's a wrapper for mysql_escape_string() that does the right escaping regardless of whether or not magic quotes is set. For my programs I know if magic quotes is set, so I use mysql_real_escape_string() directly. Here is the "headers already sent" thread: http://www.phpfreaks.com/forums/index.php/topic,37442.0.html
  3. You'll need to change both the functions and the arguments. They all have much the same names but they are called slightly differently. The first thing you need to do is get the connection working - don't bother with any of the rest until that's done. It will need to use the username you have set up for MySQL. Luckily the SQL will be much the same .. you may have to change some of the table definitions though (the "CREATE TABLE"s).
  4. Can you give us the final HTML that works in Firefox but not IE? That's easier to work with than the php that generates it, seeing as it looks like an HTML interpretation issue.
  5. @Pfmabismad: <?php function a() { global $g; $g = "I'm global\n"; } function b() { global $g; print $g; } a(); b(); ?>
  6. PFmabismad, he is declaring it as global within both functions. So it's a global variable. I'm guessing the reason it's not working is something to do with the flow of control, but it's difficult to tell with just a program fragment. And the whole program would be quite large. Frank, perhaps you can try printing out the value of the variable at different stages in the program, also printing out something to identify what part of the program it's getting printed from. Then you can see how its value changes during execution.
  7. The mail() needs to be after the closing brace of the while loop. But since it uses variables which are reset each time through that loop, you also need a way for it to combine all those variables. What I would do is start building the email message, and add to it each time through the while loop. Then send it once afterwards. So you would create $msg before the while loop, add to $msg inside the while loop, and send $msg after the while loop.
  8. Can you be more specific about what you want? There's many ways you can combine data from two tables.
  9. Are you expecting the variable to keep its value between script runs? Ie, you access one url and the variable is set, then you access another url and the variable is checked?
  10. Usually I put the class in one file, eg classes/Registration.php. Then I would include that in registration.php (with require_once('class/Registration.php')), and instantiate the class in registration.php Yes to the first two options, and I wouldn't recommend the third option. A lot of classes implement both those first two options. But the third option is mixing the interface (where the data comes from, and where it's displayed) with the processing logic (in the Registration class), which I generally don't recommend. It can make sense in some situations though. Again, don't mix your interface with the logic! Have your class return values only, and the output can be done by the code that instantiated and uses the class. If you need to format your values in a specific way, you can have the class do formatting, but make sure it returns the string instead of outputting it directly. This makes it flexible, as you can then use the result in any way you want. If the class prints it directly then it reduces your possibilities, as you can't modify the output without modifying the class. Same with the input - have the class take a data structure as input, and let the outside code handle converting $_GET or $_POST or $_REQUEST or any other data source into what the class expects.
  11. The way you're using it in the code you pasted is correct. Is it not acting how you expect it to?
  12. Did you give the port number to that script? The code has a bug and calls socket_last_error() even if it hasn't tried to connect. It's also specialized to connect back to whatever ip address connected to it, which might not be suitable.l If you're comfortable with calling functions, I would try this script: http://www.php.net/manual/en/function.socket-connect.php#84465 Otherwise try this one: http://www.php.net/manual/en/function.socket-connect.php#36223 You can try connecting to www.google.com port 80, that will never fail Do keep in mind though that you won't get any output unless you send an HTTP request first.
  13. What is RemoveSession() intended to do? If you want to change the session cookie attributes, there are configuration options described here: http://www.php.net/manual/en/session.configuration.php , with the default being "until the browser is closed". Session life depends on two things - how long the cookie survives in the browser, and how long the session file lasts on the server. The first depends on the cookie options, the second depends on your server's configuration, and sometimes can be beyond your control.
  14. There are several in the comments at http://www.php.net/manual/en/function.socket-connect.php I'm assuming you want to create a socket to connect to somewhere. There are also sockets for receiving connections. And remember that UDP sockets will ALWAYS connect, even when they are unable to send anything, because UDP is connectionless. Only TCP sockets will fail to connect.
  15. Each index can only appear once in an array, so you'll just have one 7 and one 8 in the result array, even if you merge without reindexing. I think what you are looking for is the "+" array operator. It's mentioned at http://php.net/manual/en/function.array-merge.php
  16. I think what OP was asking was "If I use mysql_real_escape_string() when storing data, do I need to mysql_real_unescape_string() when I fetch it?". The answer to that question is no. It's only needed when the data goes in. Put another way, all modifications done by mysql_real_escape_string() are removed by mysql when the data goes in. What's stored in the db is the original data.
  17. If the file is large, you could take an approach like this: 1. Read the first few lines, write them into a new file 2. Add your extra lines into the new file 3. Read the rest of the lines from the original file, write them into the new file 4. Replace the old file with the new file. That's about the best I can think of. If you do it that way, line by line, then you will have no memory issues when dealing with a large file. You do have to read every line, but there's no way around that if you're inserting text.
  18. There is no way to directly insert data into a file. Instead you need to write the extra lines you want and then write ALL the following data back to the file again. The simplest would be to read the entire file into an array, one item per line, then add the extra lines and write it all back. You could also parse the xml, edit the resulting structure and rewrite it, but that can be tricky to get right.
  19. The question of how to reset $exp_date is closely tied into where $exp_date comes from. Do you have an array of events? Are you getting them from the database? How about something like this: $events = array( array( 'exp_date' => '2010-08-01', 'start_date' => '2010-07-01', 'name' => 'July Madness', ), array( 'exp_date' => '2010-09-01', 'start_date' => '2010-08-01', 'name' => 'August Apathy', ), ); foreach ($events as $event) { $event_exp_date = $event['exp_date']; $event_start_date = $event['start_date']; $event_name = $event['name']; if (...) { } elseif ( ...) { } } Then all your conditions can go in there. The event variables will be set to the ones for each event in turn.
  20. Try this: print "Duration: " . floor($row['duration'] / 60) . ":" . floor($row['duration'] % 60); If your values really are in around 250k in size, you might need to divide by 1000 as well to get the values you want. Edit: Just re-read your question properly. Try this: print "Duration: " . floor($row['duration'] / 60000) . ":" . floor(($row['duration'] / 1000) % 60);
  21. How you get the events is relevant here. Can you show some more of your code?
  22. I'm having trouble helping you as I don't understand what you are trying to do.
  23. Is this what you want to do? $a = array(27, 9, 9); $b = array(3, 1, 1); $c = array(); for ($i = 0; $i < count($a); $i++) { $c[$i] = $a[$i] + $b[$i]; } var_dump($c);
  24. If the register_globals option is on (which it is not in modern php distributions), then $cart can be used interchangeably with $_SESSION['cart'] most of the time. The "most of the time" is why register_globals is generally not a good idea. Apart from that, using var_dump() or print_r() can give you a visual idea of the array structure. Then you can see what $_SESSION['cart'][$id] actually looks like. It's an array within another array. The outer array is $_SESSION. The inner array is $_SESSION['cart']. 'cart' is an index in $_SESSION, and $_SESSION['cart'] is its value. $id is in index in $_SESSION['cart'], and $qty is its value.
  25. isset() evaluates to on empty values such as '' or 0 or array(), could that be an issue? Also note that the elseif, because it doesn't check $_SESSION['username'], can succeed even if $_SESSION['username'] is not set. This would be clearer if it was not indented. As for debugging why it stops execution, I would add some diagnostic print statements. I often use a line like print "hello";, and I move the line around, checking whether that piece of code gets executed. After a few tries I can narrow down the exact point that execution stops.
×
×
  • 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.