Jump to content

jefkin

Members
  • Posts

    55
  • Joined

  • Last visited

    Never

Everything posted by jefkin

  1. Agreed Ken, That's a lot easier to understand and maintain. Jeff
  2. More appropriate to post the code that changes the user's image. Probably all you need to do as the last thing in the part that verifies the new image is set $_SESSION['profile_pic'] to their new image. then just to be safe call: session_write_close(); and refresh the page to wherever you need it. Jeff
  3. I've seen this error many times. It means that the variable you sent to the foreach isn't an array. This can usually be fixed by changing code like [code] if ($myCond) {     $myArray = somefunc(); } foreach ($myArray as $elem) {     // .... } [/code] into code with a preset default for the var (an empty array). [code] $myArray = array(); [/code] Trust me on this, that eror only occurs when some path to your foreach doesn't let the variable become an array. Jeff
  4. you can create an access method in class b class B extends A {   /// your stuff   function A_Hello()   {       parent::sayHello();   } } For a non invasive means, if A's sayHello method doesn't involve any class variables, you can say A::sayHello(); But the first is probaly a safer bet for anything non-trivial, and deffinitely for any method that uses class variables (instance variable).  Sometimes Global class variables will be okay. So, the absolute safest way is the first one.  Use that if at all possible. Jeff
  5. If I understand your problem, then replaceing your quoted code with my sample should work for you. So, How about foreach?  And, there's no need for the $daysMale and $daysFemale array  (along with some other stuff) [code] // your database fetch, assuming you still build $monMaleAge, $tueMaleAge, etc... $days  = array('mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun'); $ages  = array('Teen' => 'teen', '18+' => '18', '21+' => '21'); foreach ($days as $day) {     $varDB                = "{$day}MaleAge";     $daysMaleImage[$day]  = "<img src=\"images/M{$ages[$$var]}.gif\" width=\"21\" height=\"18\" />";     $varDB                = "{$day}FemaleAge";     $daysFemaleImage[$day] = "<img src=\"images/F{$ages[$$var]}.gif\" width=\"21\" height=\"18\" />"; } // to output your built arrays: echo "<table><tr><th>Day</th><th>Male</th><th>Female</th></tr>\n"; foreach ($days as $day) {     echo "<tr><td>$day</td><td>{$daysMaleImage[$day]}</td><td>{$daysFemaleImage[$day]}</td></tr>\n"; } echo "</table>\n"; [/code] If this doesn't do quite what you want, it should be close, though, I didn't actually test it. Jeff
  6. Um, what about 37  do you want 37.00 or 37.0  ??? Do you mean signifigant figures? How about .00002323  do you want .000  or do you want .0000232 round() provides some functionality you might find useful. Jeff
  7. [code] $sigfig = 2; for ($i = 2; $i < 15; $i ++) //  use a bigger number if 15 is too small {     $var  = "col$i";                        // store the working var name col2, col3, etc...     $$var = round($$var, $sigfig); // set and round the variable named 'col2', 'col3', etc... } [/code] Jeff
  8. Hi lJesterl change the echo code bit from: [code] for ($i=0; $i <$num_results; $i++) { $row = mysql_fetch_array($result); echo"<tr>"; echo"<td>"; echo ($row["ip"]); echo"</td>"; echo"<td>"; echo ($row["entries"]); echo"</td>"; echo"</tr>"; } [/code] to [code] for ($i=0; $i <$num_results; $i++) {   $row    = mysql_fetch_array($result);   $iplist .= "<tr><td>{$row['ip']}</td><td>{$row["entries"]}</td></tr>"; } [/code] Jeff
  9. Hi bob_the_builder, trim()  only removes leading and trailing spaces from the string, so: "    Hello  World      " is changed to "Hello World" And "  MY      name      is      Jeff  " becomes "MY      name      is      Jeff" As for your second question, if your data is numeric, and simple, such as $_SESSION['user_id'] as an integer, then there's no need to 'clean' it. Generally if you're passing complicated data, including spaces, or funky chars, then you use $my_url = "index.php?action=user&user_id={$_SESSION['user_id']}&my_funky_chars=" . urlencode($_SESSION['funky_chars']); Doe that cover it ? Jeff
  10. For a one time fix for your articles, first look in the database and find out your authorid.  For my example, I'm assuming your authorid is 133, if you have a different one (probably) just change the SQL below to use your number instead of 133. then from mysql or from MysqlAdmin of your favorite flavor, run this command: [code] UPDATE articles SET visible = 'Y' WHERE authorid = 133; [/code] This will enable all your articles. HTH Jeff
  11. Hi Tunnleram, looks like you need to change this line: [code] $query = "INSERT INTO user (host, user, password, select_priv, insert_priv, update_ priv) VALUES ('localhost', '$username', PASSWORD('$password'), 'Y', 'Y', 'Y')"; [/code] into this: [code] $query = "INSERT INTO user (host, user, password, select_priv, insert_priv, update_priv) VALUES ('localhost', '$username', PASSWORD('$password'), 'Y', 'Y', 'Y')";                                                                             ^^^^^^^^^^^ [/code] The 'update_'  and the 'priv' need to go together!! Jeff
  12. Slight typo, I think onlyican, [quote author=onlyican link=topic=107532.msg431588#msg431588 date=1157893699] [code] <?php function getImap() { global $servername; global $username; global $password; $mbox = imap_open("{".$servername.":110/pop3/notls}INBOX", $username, $password); return $mbox; } $mbox = getImap(); $mcheck = imap_check($mbox); $mnum = $mcheck->Nmsgs; $overview = imap_fetch_overview($mbox, "1:$mnum", 0); ?> [/code] [/quote]
  13. A minor suggestion, onlyican, If you want to avoid javascript, You could save the entered data in a mysql table, then let the browser load right on top.  Once the user's selected the recipient, you can retrieve it. Another way that might fit the bill better:  To acomplish almost the same thing you could use sessions.  So once they hit the 'select user' button or whatever, it saves the entered stuff in the session and opens the recipient chooser page.  The chooser page let's them pick and when they resubmit, grab their stored session data and display it along with the user. HTH Jeff
  14. to echo it, change this: [code] while ( $arr = mysql_fetch_array($res) ) eval($arr[0]); [/code] to this: [code] while ($arr = mysql_fetch_array($res)) {   echo "<pre>{$arr[0]}</pre>\n";   eval($arr[0]); } [/code] It will still die at the same place, but your ouput should include a bunch of  *whatevers* you keep in 'Conf' field in the database table Modules. when it dies, look at the last output before the death, and count down to line 13...  That's your error. Jeff
  15. You may be right tleisher, but without his code, I just guessed that he's having a problem retrieving the '\' on the php side.  before he could get to it with a str_replace(). Maybe I missunderstood.  If so, appologies rshadarack. Otherwise, I'm thinking the problem is he's got magic_quotes or some such set to muddle with his form input strings. Like I said, could be wrong... Jeff
  16. Hi Wenonae, I tried the exact headers in your post, but that didn't cut it.  Instead I had to sort of merge somethings from yours and my original. Since it wasn't just a cut and paste, I've included the final code: [code] if (!preg_match('/\.txt/', $file)) {   die("not a valid '.txt' file request $file"); } elseif (preg_match('/\.\./', $file)) {   die("invalid path characters '..' in file request $file"); } else {   if ('/' == substring($file, 0, 1))   {     $file = substring($file, 1);   }   $url  = "/var/www/html/$file";   $name = basename($url);   $size = filesize($url);   header('Pragma: public');   header('Cache-control: cache, must-revalidate');   header("Accept-Ranges: bytes");   header('Content-Type: application/octet-stream');   header("Content-Transfer-Encoding: Binary");   header('Content-Description: File Transfer');   header("Content-Disposition: attachment; filename=\"$name\";");   header("Content-Length: $size");   @readfile($url) OR die(); } ?> [/code] But thanks for your help.  With it, I got this to work.  And maybe this will work for other people who find themselves in a similar fix... :) Jeff
  17. hi jrswastaken, Sounds like something libcurl could help you with.  [url=http://us3.php.net/manual/en/ref.curl.php]http://us3.php.net/manual/en/ref.curl.php[/url] [url=http://us3.php.net/manual/en/function.curl-init.php]http://us3.php.net/manual/en/function.curl-init.php[/url] [url=http://us3.php.net/manual/en/function.curl-exec.php]http://us3.php.net/manual/en/function.curl-exec.php[/url] [url=http://us3.php.net/manual/en/function.curl-close.php]http://us3.php.net/manual/en/function.curl-close.php[/url]
  18. straight from the source: [url=http://us3.php.net/manual/en/function.opendir.php]http://us3.php.net/manual/en/function.opendir.php[/url] [code] <?php $dir = "/etc/php5/"; // Open a known directory, and proceed to read its contents if (is_dir($dir)) {   if ($dh = opendir($dir)) {       while (($file = readdir($dh)) !== false) {           echo "filename: $file : filetype: " . filetype($dir . $file) . "\n";       }       closedir($dh);   } } ?> [/code] Jeff
  19. Woops! Okay, my bad then, add: array_pop($fields);  right after the first while. That should kill the naughty extra line. :) Jeff
  20. Hi, rshadarack, Sounds like a client side issue, so you could alway write some javascript to do it ... but ... the problem with replacing them in the client's html side is they're turned back into backslashes when it transfers to the server. Your real problem, as you can guess, is that once in the server side they can be stripped out depending on your PHP ini settings.  I'm not much of a sys-admin type, but there are some others here that can probably point you in the right direction. Jeff
  21. wenonae, I think this might do it.  However, since it's after dark on a Saturday night, and I don't have an ie machine hanging around, I'll have to test it tomorrow or worst case monday :) But I'll send a preemptive 'Thank you'!!! (If you're the same wenonae as on the other formum, cool, you earned yourself a double Thank-you!!) Jeff
  22. Sure Azsen, and it should make your page load faster, especially if the outer loop repeats alot. Why not just rip it out of there?  I also tried to make the output more w3c compliant. [code] /* ** extracted from loop for efficiency */ $fields    = array(); $resultB = select("select * from field order by FieldName"); while ($fields[] = mysql_fetch_array($resultB)) ; /* ** regular loop */ $result = select("select * from games"); while ($row = mysql_fetch_array($result)) {     $gameId        = $row['GameID'];     $roundNum      = $row['RoundNum'];     $gameFieldId    = $row['FieldID'];     $gameDateTime = $row['DateTime'];     echo "<tr><td><select name=\"field$count\">";     foreach ($fields as $filedId => $field)     {         $selected = ($fieldID == $gameFieldId) ? ' selected="selected"' : '';         echo "<option$selected value=\"$fieldId\">{$field['FieldName']}</option>";     }     echo "</select></td></tr>"; } [/code] ... oh, Barand beat me too it, but since I typed it in... Jeff
  23. Try running the wordwrap prior to the smiley replacements. That might be the trick. Jeff
  24. Hi bandit, I don't think this will solve your problem, but may help locate it specifically, as I count it, this is line 8 in your code: [code] $_SESSION['image_random_value'] = md5($rand); [/code] With that error, it seems to me that it's choking on the 'image_random_value'. If I've counted right, then this is just a dummy test, but try putting new lines in the code like this: [code] $rand = $rand; // see if error might be from above then should give this line as error again. $_SESSION[ 'image_random_value' ] = md5( $rand ); [/code] See if or how the line number changes, to pinpoint what is causing the problem.  Good Luck. Jeff
×
×
  • 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.