Jump to content

roopurt18

Staff Alumni
  • Posts

    3,746
  • Joined

  • Last visited

    Never

Everything posted by roopurt18

  1. I've never benchmarked it so I couldn't say. Are you trying to perform file attachments? Is the message body very large? Are you able to identify which area of your code is actually causing the out of memory error?
  2. Only if you intend to keep using "\n" as your newline character and want to view it on windows. You just have to be mindful of which OS this text file will be viewed on. Most text editing programs are smart enough to treat \n, \r, and \r\n the same, meaning they cause a carriage return linefeed. Notepad is the only text editor I'm aware of that doesn't know what to do with them. So if you're generating text files that will be e-mailed to non-tech savvy users, then you should use \r\n. Otherwise \n is typically preferred.
  3. Learning how to pick keywords out of text will serve you well in the future. But I'll help you! "I'm not sure what they're using, but you can achieve the same thing with XHR (also called AJAX (which is a stupid term that should go away)). The simple idea is to use JavaScript to have the user's browser poll the site asking if there are any updates. If there are, you bring them in and update the HTML with DOM API. The fancier version is to install an ActiveX or Java applet on the user's machine and the server pushes the updates to the clients; this way you don't have to have clients constantly polling the crap out of your site."
  4. Open the file in Wordpad instead of Notepad. http://www.php.net/manual/en/function.fopen.php For the explanation why, ead the note that starts: Notepad isn't smart enough to put "\n" by itself on a newline. It requires "\r\n".
  5. <?php $username = mysql_real_escape_string($_SESSION['myusername']); // escape input going INTO the database $query = "SELECT user_info.username, user_info.`password`, user_info.UserID, user_info.EmailAddress, user_info.Address, user_info.Postcode, user_info.FirstName, user_info.LastName FROM user_info WHERE user_info.username = '$username'"; $results = mysql_query($query) // DONT escape the entire SQL query...BAD BAD BAD or die(mysql_error()); while ($row = mysql_fetch_array($results)) { extract($row); echo $username; echo $password; echo $UserID; echo $EmailAddress; echo $Address; echo $Postcode; echo $FirstName; echo $LastName; } ?> Bleh, ken beat me to it!
  6. Don't duplicate post; you already have a topic for this.
  7. Configure phpbb3 to connect to MySQL? I'm sure you have to set a host, user, password, and database for phpbb3 to use. Just guessing here, I've never used phpbb3.
  8. I'm not sure what they're using, but you can achieve the same thing with XHR (also called AJAX (which is a stupid term that should go away)). The simple idea is to use JavaScript to have the user's browser poll the site asking if there are any updates. If there are, you bring them in and update the HTML with DOM API. The fancier version is to install an ActiveX or Java applet on the user's machine and the server pushes the updates to the clients; this way you don't have to have clients constantly polling the crap out of your site.
  9. In option-tags, whatever is set as the value-attribute is what you'll get in post. So put what you want there. If you don't want the index, then don't assign value="$index"; instead, assign value="$value". <?php $selected = $counter == $sticky ? ' selected="selected"'; $htmlval = htmlentities( $value, ENT_QUOTES ); echo sprintf( '<option value="%s"%s>%s</option>', $htmlval, $selected, $htmlval ); /* replaced by above if ($counter == $sticky) { echo '<option value="' . $index .'" selected>' . $value . '</option>'; } else { echo '<option value="' . $index .'">' . $value . '</option>'; } */ ?>
  10. And strings in MySQL are surrounded by single quotes, not double quotes.
  11. You don't escape the whole SQL string; only the variables you substitute into it.
  12. I need to know what the exact code is that you are using. Depending on how you are adding the timestamp, then yes it could be the reason the empty rows are going in.
  13. Are you modifying the code that I'm posting? I want to know how roster_date is being added to the inserted data.
  14. People do all sorts of things with log files. They download them off their server onto their local PC. They write cron scripts to take the most recent log entries and e-mail them places. They send log output to development teams for bug elimination. They post log output to forums, newsgroups, and mailing lists. Developers sometimes send the log information to project managers or (worse) non-technical managers who then ignorantly forward them around. Just because someone is reading the log information doesn't mean they've compromised the actual server. If it's just for one person, then I don't really see it as a problem. The developer could easily explain what this means to that single user and train them on how to configure the browser to always trust the certificate. That way you're only told kittens will explode just the one time! (Unless you switch browsers.)
  15. Fair enough. You'd be surprised though how many people ask for help without making a solid attempt on their own though. The next step would be to try and get more information as to why it's failing. Turn on error reporting if it's not already. See if those image*() functions have a way of returning extended error information and check that information at every step of the way. And double check your version of any extension you're using for known bugs and / or problems. If all else fails, upload or send me a copy of your png and if I have time I can try to run it on my machine.
  16. I've never used the PHP image functions to do such a thing, so I know nuts about them. But maybe one of these will help you: http://www.google.com/search?rlz=1C1GGLS_enUS330US330&sourceid=chrome&ie=UTF-8&q=php+add+a+png+watermark
  17. I know this is solved, but this may also come in handy next time you face a similar problem: http://www.php.net/manual/en/function.clearstatcache.php
  18. IIRC IE does not like it when you modify an existing table. It doesn't matter which you use, DOM model or innerHTML, IE farts all over it. One solution is to rebuild the entire table HTML string, from the opening table-tag to the closing table-tag and set the innerHTML of the parent of the table. This will work in IE. However since this is a form it may be difficult to preserve the existing form data entered into the fields. Another, simpler method, is to just output the entire table regardless of which subject selection is chosen. Create the following CSS class: .hidden { display: none !important; } Then in your JavaScript code, since the entire table is already output, you won't have to set innerHTML at all. Instead you can just add / remove the hidden class to table rows, cells, or inputs. Most of the existing JavaScript libraries support addClass(), removeClass, etc. This is what I'd do.
  19. It shouldn't be logged at all. Allowing it to be logged allows for potential attackers to see a history of generated passwords. This could clue an attacker in on the characteristics of your password generator and the type of passwords it produces. That information could potentially be abused. Call me paranoid...
  20. Sounds like a take home quiz to me.
  21. Empty your table again. I'd like to see the debug output of this script for the following three scenarios: 1) The initial load when the table is empty. 2) The output after submitting the form. 3) The output when the page is requested AND players exist in the database. <?php require('includes/application_top.php'); // if the customer is not logged on, redirect them to the login page if (!tep_session_is_registered('customer_id')) { $navigation->set_snapshot(); tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL')); } ?> <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"> <html <?php echo HTML_PARAMS; ?>> <head> <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>"> <title><?php echo TITLE; ?></title> <base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>"> <link rel="stylesheet" type="text/css" href="stylesheet.css"> <?php require('includes/form_check_coach.js.php'); ?> </head> <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0"> <!-- header //--> <?php require(DIR_WS_INCLUDES . 'header.php'); ?> <!-- header_eof //--> <!-- body //--> <?php mydbg( 'POST: ' ); mydbg( $_POST );//%% if( !empty( $_POST ) ) { /** * If you print_r( $_POST ) you will find that you have an array named 'players'. * Each index into this array will be POSITIVE and the players database ID if they already exist in the database * The index will be NEGATIVE if the player is new and needs to be inserted. * * And then each player is an array where the associative names should match your column names, * so that you can easily generate your insert / update statements based on what I * showed you earlier. */ foreach( $_POST['player'] as $player_id => $player_info ) { foreach( $player_info as $k => $v ) { $player_info[$k] = "'" . mysql_real_escape_string( $v ) . "'"; } // ADDED A CHECK FOR IF THE PLAYER IS EMPTY! $emptyplayer = $player_info; // Copy the array unset( $emptyplayer['customer_id'] ); // Remove customer_id from empty player $emptyplayer = !strlen( trim( implode( " ", $emptyplayer ) ) ); // true if empty, false otherwise mydbg( 'Empty Player:' );mydbg( $emptyplayer );//%% if( $player_id < 0 ) { if( $emptyplayer ) { mydbg( 'Skipped player' );//%% continue; // SKIP TO NEXT PLAYER } // OOPS! SINCE 'player_id' IS AUTO-INCREMENTING, WE DO NOT HAVE TO INSERT IT. // THEREFORE THE FOLLOWING LINE IS COMMENTED OUT (i.e. you can remove it from your code). //$player_info['player_id'] = "'" . mysql_real_escape_string( $player_id ) . "'"; $stmt = "insert into `rosters` ( " . implode( ', ', array_keys( $player_info ) ) . " ) values ( " . implode( ', ', $player_info ) . " )"; mydbg( 'Insert player' );//%% }else if( !$emptyplayer ){ // player_id GREATER THAN ZERO, SO PLAYER EXISTS IN DATABASE. PLAYER IS NOT // EMPTY, SO WE UPDATE HIM! foreach( $player_info as $k => $v ) { // SLIGHTLY MORE READABLE $player_info[$k] = "`{$k}`={$v}"; } $stmt = "update `rosters` set " . implode( ', ', $player_info ) . " where " . "`player_id`='" . mysql_real_escape_string( $player_id ) . "'"; mydbg( 'Update player' );//%% }else{ // player_id GREATER THAN ZERO SO HE EXISTS IN DATABASE. PLAYER IS EMPTY // SO WE DELETE HIM! $stmt = "delete from `rosters` where `player_id`='" . mysql_real_escape_string( $player_id ) . "'"; mydbg( 'Delete player' );//%% } $r = mysql_query( $stmt ); // check for errors and success if( !$r ) { mydbg( $stmt );//%% mydbg( mysql_error() );//%% } } } echo "<form action=\"roster.php\" method=\"post\"><table>"; mydbg( 'Select players:' ); mydbg( $sqlplayers );//%% $result = mysql_query( $sqlplayers ); $maxrows = 15; $insid = -1; // create a blank player template $cols = array( 'fname' => 'size="10"', 'lname' => 'size="10"', 'address' => 'size="15"', 'city' => 'size="15"', 'state' => 'size="2"', 'zip' => 'size="10"', 'phone' => 'size="10"', 'email' => 'size="20"', 'number' => 'size="2"', 'gradyear' => 'size="4"', 'height_feet' => 'size="1"', 'height_inches' => 'size="4"' ); $blankplayer = array(); foreach( $cols as $c => $extra ) { $blankplayer['player_roster_' . $c] = ''; // MODIFIED TO ADD player_roster_ prefix } // we now have a blank player template for( $i = 1; $i <= $maxrows; $i++ ) { echo "<tr>"; if( $result ) { $player = mysql_fetch_assoc( $result ); mydbg( $player );//%% } if( !$player ) { // We've run out of players, so create a blank one to insert $result = null; // stop trying to access result $player = $blankplayer; $player['id'] = $insid--; // first blank player is id -1, second is -2, third is -3, etc. } // dump the fields $firstcol = true; foreach( $cols as $c => $extra ) { $c = 'player_roster_' . $c; // MODIFIED TO ADD player_roster_ prefix echo "<td>"; if( $firstcol === true ) { echo "<input type=\"hidden\" name=\"player[{$player['id']}][customer_id]\" value=\"{$customer_id}\" />"; } echo tep_draw_input_field( "player[{$player['id']}][{$c}]", $row[$c], $extra ) ."</td>"; } $player = null; // important! echo "</tr>"; } ?> </table><input type="submit" name="editplayers" value="Submit" /> </form> <?php mydbg( null, false ); /*%%REMOVE ME dump debugging */?> <!-- footer //--> <?php require(DIR_WS_INCLUDES . 'footer.php'); ?> <!-- footer_eof //--> </body> </html> <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?> <?php /** * Simple debugging function. If $add is true, it adds debugging message. If $add is * is false, it dumps debugging messages that were added. * * @param mixed $msg * @param bool $add */ function mydbg( $msg, $add = true ) { static $msgs = array(); if( $add === true ) { $msgs[] = $msg; }else{ echo '<pre style="text-align: left; font-weight: bold; font-size: 10px; background-color: #ececec;"> DEBUG:'; foreach( $msgs as $msg ) { if( is_bool( $msg ) ) { $msg = 'BOOLEAN [' . ($msg ? 'T' : 'F' ) . ']'; }else if( is_null( $msg ) ) { $msg = '__NULL__'; }else if( is_string( $msg ) && !strlen( $msg ) ) { $msg = '__EMPTY_STRING__'; }else if( is_array( $msg ) || is_object( $msg ) ) { $msg = print_r( $msg, true ); } echo $msg . "\n\n"; } echo '</pre>'; } }
  22. Check your server settings as suggested. If it doesn't help then I'd start thinking of ways to reduce the load caused by those types of queries in particular. If you're managing a database of such magnitude, I'd imagine you already know this, but I'll toss it out there anyways. On those large table JOINs, if the number of join columns is not large, consider making indexes on just the columns involved in the joins if you don't have those indexes already. MySQL will plow through the JOIN conditions much faster if all the data it needs for the join is contained in an index. For example if 3 columns are joined and only two of them are in a usable index, then MySQL will still have to refer to the actual table to pull the third value to determine if a join is necessary. Are you having any problems with insert or update performance? If so then you may have too many indexes.
  23. I started my website when it was starting to look like I'd need to find a new job. I also like teaching. So the purpose of my site is mainly to educate and demonstrate some of my technical (and writing) skills. I don't have any pages on the internet where I expose details of my personal or social life. No facebook. No myspace. No linkedin. No twitter; I don't even know what twitter is. Human resources departments now look for potential employees on the internet to see what kind of personal lives they run, which directly affects whether they hire you or not. I'm also anti-social, so I don't have the codependent behavior of caring if other people know what my current mood is or if I were a movie quote which one would I be.
  24. http://www.google.com/search?rlz=1C1GGLS_enUS330US330&sourceid=chrome&ie=UTF-8&q=gnu+audio+software
×
×
  • 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.