Jump to content

ignace

Moderators
  • Posts

    6,457
  • Joined

  • Last visited

  • Days Won

    26

Everything posted by ignace

  1. It's not the usual way, it's the only way. Visitors/users are something entirely different from DB users. DB users have access to your database, where a visitor/user has not.
  2. if the password is admin (and it's stored like that in your DB) then you should not MD5() it.
  3. public static function authenticate($username, $password){ try { $dbh = new PDO("mysql:host=localhost;dbname=myDB", $username, $password); $dbh = null; return 1; } catch(PDOException $e){ $dbh = null; return 0; } } You should validate the user against a db table not as a db user. class Users { private $_pdo; public function __construct(PDO $driver) { $this->_pdo = $driver; } public function authenticate($user, $pass) { $sql = 'SELECT * FROM users WHERE username = ? AND password = ?'; $stmt = $this->_pdo->prepare($sql); $stmt->bindValue(0, $user); $stmt->bindValue(1, $pass); $stmt->execute(); return $stmt->rowCount() == 1 ? $stmt->fetch() : false; } }
  4. If the price is right, clients will forget about their customers' (experience) and drop IE7 like a rock!
  5. If it is not php 5.4 then you can't use array dereferencing. Store it in a variable and acccess it like that.
  6. Either alias the column or access them using their numeric indices. tbl2.description as description2 OR $row[3]
  7. If you have trouble setting up a DB schema for friend lists then take a look at: http://stackoverflow.com/questions/4674005/setting-up-a-friend-list-in-mysql
  8. XML is not faster than MySQL. And with 40000 queries your XML solution will completely bog down your server while MySQL would only be getting warmed up.
  9. LOL Care to elaborate? I am running PHP 5.4 under Windows and trying to use the money_format() function returns: Which is the same error as the OP while you stated it was due to an old version of PHP, which it is not.
  10. He is running Windows and per the manual: You can try this function that you can find on the manual page as a replacement: http://be2.php.net/manual/en/function.money-format.php#89060 function money_format($format, $number) { $regex = '/%((?:[\^!\-]|\+|\(|\=.)*)([0-9]+)?'. '(?:#([0-9]+))?(?:\.([0-9]+))?([in%])/'; if (setlocale(LC_MONETARY, 0) == 'C') { setlocale(LC_MONETARY, ''); } $locale = localeconv(); preg_match_all($regex, $format, $matches, PREG_SET_ORDER); foreach ($matches as $fmatch) { $value = floatval($number); $flags = array( 'fillchar' => preg_match('/\=(.)/', $fmatch[1], $match) ? $match[1] : ' ', 'nogroup' => preg_match('/\^/', $fmatch[1]) > 0, 'usesignal' => preg_match('/\+|\(/', $fmatch[1], $match) ? $match[0] : '+', 'nosimbol' => preg_match('/\!/', $fmatch[1]) > 0, 'isleft' => preg_match('/\-/', $fmatch[1]) > 0 ); $width = trim($fmatch[2]) ? (int)$fmatch[2] : 0; $left = trim($fmatch[3]) ? (int)$fmatch[3] : 0; $right = trim($fmatch[4]) ? (int)$fmatch[4] : $locale['int_frac_digits']; $conversion = $fmatch[5]; $positive = true; if ($value < 0) { $positive = false; $value *= -1; } $letter = $positive ? 'p' : 'n'; $prefix = $suffix = $cprefix = $csuffix = $signal = ''; $signal = $positive ? $locale['positive_sign'] : $locale['negative_sign']; switch (true) { case $locale["{$letter}_sign_posn"] == 1 && $flags['usesignal'] == '+': $prefix = $signal; break; case $locale["{$letter}_sign_posn"] == 2 && $flags['usesignal'] == '+': $suffix = $signal; break; case $locale["{$letter}_sign_posn"] == 3 && $flags['usesignal'] == '+': $cprefix = $signal; break; case $locale["{$letter}_sign_posn"] == 4 && $flags['usesignal'] == '+': $csuffix = $signal; break; case $flags['usesignal'] == '(': case $locale["{$letter}_sign_posn"] == 0: $prefix = '('; $suffix = ')'; break; } if (!$flags['nosimbol']) { $currency = $cprefix . ($conversion == 'i' ? $locale['int_curr_symbol'] : $locale['currency_symbol']) . $csuffix; } else { $currency = ''; } $space = $locale["{$letter}_sep_by_space"] ? ' ' : ''; $value = number_format($value, $right, $locale['mon_decimal_point'], $flags['nogroup'] ? '' : $locale['mon_thousands_sep']); $value = @explode($locale['mon_decimal_point'], $value); $n = strlen($prefix) + strlen($currency) + strlen($value[0]); if ($left > 0 && $left > $n) { $value[0] = str_repeat($flags['fillchar'], $left - $n) . $value[0]; } $value = implode($locale['mon_decimal_point'], $value); if ($locale["{$letter}_cs_precedes"]) { $value = $prefix . $currency . $space . $value . $suffix; } else { $value = $prefix . $value . $space . $currency . $suffix; } if ($width > 0) { $value = str_pad($value, $width, $flags['fillchar'], $flags['isleft'] ? STR_PAD_RIGHT : STR_PAD_LEFT); } $format = str_replace($fmatch[0], $value, $format); } return $format; }
  11. What's not fair about it? If you want a better portfolio website then get to it!
  12. $array[] = array(postcount($row['username']) => $row['username'].':'.$row['lastlogin']); Creates a new entry for each user in $array. To be able to access postcount, username, and such in an easy way it's best to use: $array[] = array('postcount' => postcount($row['username']), 'username' => $row['username'], 'lastlogin' => $row['lastlogin']); Acessing the first player's postcount: $array[0]['postcount']; While you would have to get creative with the example at the top of this post to get the same info: key($array[0]);
  13. Use extract function trace_log($array) { if (is_array($array)) { extract($array); $sql = "INSERT INTO reg_log_trace( step, file, script, func, line, var_name, var_value ) VALUES ( 0,'{$myfile}','{$script}','{$func}', {$line}, '{$var_name}', '{$var_value}' )"; db_query($sql); } .. }
  14. It also makes him "valid".
  15. My guess would be "Cannot redeclare function replacesmiley()" move the smiley function out of the while() loop. EDIT: OP beat me to it.
  16. 3 years? Has it already been that long?
  17. Then report they have an RFI issue they need to resolve.
  18. Like PFMaBiSmAd already pointed out your table appears to be sorted by username. CTRL+U and view the source whether it has been correctly sorted there.
  19. Alternative options are: A) model the relation and take advantage of the relational model: comments (comment_id) blog_comments (blog_entry_id, comment_id) artwork_comments (artwork_id, comment_id) profile_comments (profile_id, comment_id) because the type column has a few drawbacks which you may not have considered, it's difficult for example to left join using a value in a type column. B) create a comments table for each type instead of just having one comments table.
  20. Head on over to the phpfox website and contact their support. If there is an exploit in their software you must be able to download a patch.
  21. basename echo basename($_SERVER['PHP_SELF']);
  22. http://www.php.net/manual/en/function.headers-list.php then.
  23. http://www.php.net/manual/en/function.apache-request-headers.php returns the headers of the current request.
×
×
  • 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.