Jump to content

snorky

Members
  • Posts

    55
  • Joined

  • Last visited

    Never

Contact Methods

  • MSN
    greywolf_pnw@hotmail.com
  • Website URL
    http://www.ohsd.net

Profile Information

  • Gender
    Not Telling
  • Location
    Pacific Northwet - US of A

snorky's Achievements

Member

Member (2/5)

0

Reputation

  1. Oddly enough, I tried that (or something similar, apparently omitting/goofing up a step). Following your instructions fixed it. Thank you.
  2. MySQL 4.1 CentOS 4.5 NOTE: I have more than a full-time job administering a network with 2500+ nodes and 6000+ end users. Since these old versions of MySQL and CentOS have been working, I haven't updated them. "If it ain't broke, don't fix it." That said, the server that hosts the mysql server got hit by an unexpected power-down -- someone was testing the backup power generator ... I have several databases on that instance of mysql. All seemed to have survived - except, of course - the most important one. On the 'other' DBs, users can run the php/html programs and access data without problems. Note: everything on this MySQL server has run smoothly for several years prior to the big hit. On the 'big' database - the one that is now suffering - [*]the users cannot access the server; for these users the PHP performs only SELECT functions [*]the maintainers - the people whose PHP performs SELECT, INSERT, DELETE, UPDATE functions cannot access the server [*]the DBA - me - cannot use PHP, the MySQL console, and Webmin to access data note: I don't use PHPAdmin on this - phpmyadmin broke after an update and I never bothered to fix it The failed commands and the error messages errors: users: $link=mysql_connect('xxx.xxx.xxx.15','guest',''); PHP CODE: if (!$link) { die('Unable connect to the server at this time. Version 20110216.1155: '. mysql_error()); } ERROR MSG: Unable connect to the server at this time. Version 20110216.1155: Access denied for user 'guest'@'xxx.xxx.xxx.22' (using password: NO) MAINTAINERS: CODE: $link=mysql_connect('xxx.xxx.xxx.15','maintainer','password'); { die('Unable connect to the server at this time. Version 20091006.1300: ' . mysql_error()); } ERROR MSG: Unable connect to the server at this time. Version 20091006.1300: Access denied for user 'maintainer'@'xxx.xxx.xxx.22' (using password: YES) DBA: COMMANDS/ERROR MSGS: I get a panoply of errors, depeding on what I'm doing. Whether I log on to mysql as root or as dba, all of the errors refer to user '' mysql -u root -p --- I no longer need a password for root or dba when SELECTing from the mysql table, the passwords for root dba display in plain text, instead of encrypted mysql> SET PASSWORD FOR 'dba'@'localhost' = PASSWORD('newpass'); ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'mysql' Note that the user is '' mysql> UPDATE mysql.user SET Password=PASSWORD('newpass') WHERE User='dba' AND Host='localhost'; ERROR 1142 (42000): UPDATE command denied to user ''@'localhost' for table 'user' I get the error command denied to user '' with any db admin statements such as SELECT, INSERT, UPDATE, SET, DELETE. As a result, I cannot create a new user or superuser, elevate the privileges for an existing user, delete existing users. For example, using Webmin, Failed to delete users : SQL delete from user where user = 'dba' and host = '' failed : DELETE command denied to user ''@'localhost' for table 'user' I have yesterday's mysqldump of this (and each) non-system database, i.e., all but the mysql DB. However, I don't see where restoring the non-problem DBs' data will solve the problem of users, passwords, and privileges. It appears to me that the mysql DB is corrupted. Is there a way to fix that? Or am I (as usual) going off half-cocked?
  3. (whacks self upside the head) Regex ! Of course! I spent hours going down the wrong path, running down a ditch. Thank you.
  4. mysql select ... where ... in or like Consider these statements: Code: select * from[i] sometable[/i] where[i] thiscolumn[/i] in(1,2,3); That returns all rows where column thiscolumn is one of those three values. Code: select * from [i]sometabl[/i]e where [i]thiscolumn[/i] like("a%"); That returns all rows where the first character of a column thiscolumn is 'a'; What I'm trying to do is to combine the two concepts as in something like select * from [i]sometable[/i] where [i]thiscolumn[/i] in('like("b%")','like("c%")'); I'm trying to return all rows where the first character of a column thiscolumn is 'b' or 'c'; That syntax is wrong. I've tried assigning variables set @var1: 'like="b%"'; set @var2: 'like="c%"'; then using those vars in the in predicate. select * from [i]sometable[/i] where [i]thiscolumn[/i] in('b','c'); Again, bad syntax. I could use ... Code: thiscolumn like("b%") or thiscolumn like("c%") or thiscolumn like("da%") or .... ... ad nausem. But if there are many values in the set, it becomes quite clunky. I've tried the mysql manual and google. The problem with those is trying to figure out how to ask the question. A forum like this gives me the ability to (hopefully)seek, explain, and find the solution. In this case I don't have the luxury of using php; I have to do it within mysql. Ideas? __________________ Certified Digital Forensics Examiner, MCSE, etc., etc. Nature: Nerd. Nurture:Linux
  5. That makes sense. Thanks. However.... the script still does not return what I expect. If I throw in some debugging code, I can see that "everything" would work correctly if the values of $a and $c (in the complete script at the bottom) are passed from getValues() to lookUps(). [ pseudo code ] : getValues() $a = [statementX] $inputFile; return $a; lookUps() global $a; $aa = "nslookup" . $a; exec($aa); // This is not the problem. // The problem is that there is nothing to execute (see below). loop0() global $a; while(!feof($inputFile)) // repeats lookUps() until feof($inputFile) { $values = getValues(); lookUps($values); } lookUps() should process $a to create $aa - an argument for an execute statement: exec(), shell_exec(), passthru(), etc. However, no value for $a is passed to this function. I can tell there is no value by testing for $a before the $aa assignment. Using or not using the global and return statements makes no difference. $a is not passed from getValues() to lookUps(). The early parts of the script (see below) work well. In other words, the values for $a and $c are created correctly. I don't like to ask so many questions, but after several hours of research and testing I'm still hitting the wall. I really appreciate the help of people far more skilled than I. The complete script is: <?php // -- run nslookup for hostname & ip address and compare results -- */ // -----begin vars ----------- $dir = "."; // folder for input and results files $thisDay = date("Ymd"); // date used in file names ex: 20100316 $fileIn = $thisDay . "-panda.txt"; // input file $fileOut = $thisDay . "-results.txt"; // results file $handleIn = fopen($fileIn,'r'); // open input file read-only $textA = " - computers without Panda\n"; // part of header line in results page $textB = $thisDay . $textA; // -----end vars ------------ // ----- begin functions ------------- function finis() // the last step in the script { global $fileIn; global $fileOut; close($fileIn); close($fileOut); exit (); } function openFileOut() // create log file { global $fileOut; global $textB; fopen($fileOut,'w'); // open the output file for write fwrite($fileOut,$textB); // print header line at top of results page // leave results page open for more writes } function openFileIn() // open input file (text) { global $fileIn; fopen($fileIn,'r'); // open the input file for read } /* --- example of values in function getValues() $data = OHE-CL30,10.11.1.59 $z = 19 // count of chars in entire line $b = 8 // location of comma $a = 0,7 "OHE-CL30" // 1st substring in $data $c = 9,18 "10.11.1.59" // 2nd substring in $data --- end example -------------- */ function getValues() { global $handleIn; global $thisDay; global $fileIn; global $fileOut; global $textA; global $textB; $data = fgets($handleIn); // the string being read // example: OHE-CL30,10.11.1.59 // each line of input file resembles this : hostname,ip address */ $z = strlen($data); // how many chars in entire line // example: 19 $b = strpos($data,","); // find the comma // example: 8 $a = substr($data,0,($b - 1)); // hostname // example: 0,7 "OHE-CL30" $c = substr($data,($b + 1),($z - 1)); // ip address // example: 9,18 "10.11.1.59" return $a; return $c; } function lookUps() // compare and reverse compare IPs & HOSTNAMES { global $a; global $c; $aa = "nslookup" . $a; $cc = "nslookup" . $c; // then use shell_exec() or exec() or passthru() } function loop0() { global $handleIn; global $a; global $c; $counter = 1; // initialize counter @1 while(!feof($handleIn)) { $values = getValues(); lookUps($values); } } // ----- end functions ------------- /* ------------ runtime ------------ */ openFileIn(); openFileOut(); loop0(); echo " ======== closing files and going home =========\n"; finis(); ?>
  6. "Functions can both accept and return values. Its a simple concept." The problem: how do I pass the values of the variables in function getValues() to function lookUps() ? Using the global declaration doesn't work.
  7. I have a script that consists of Some variables declared in the body of the script. They will become global variables used throughout the script. 5 functions: function openFileIn() - opens a text file for reading function openFileOut() - creates and opens a log file (text) for writing function loop0() - is a loop that uses global variables AND calls the next two functions(see below) function getValues() - reads one line from the input file and processes it to create variables specific to the current iteration of the loop function lookUps() - executes commands using the global variables AND (hopefully) variables created in function getValues(), writes the results to the log file, and hands control back to the while statement. All of the variables declared in the body of the script easily pass to functions by identifying them as global when using them in a function. The problem: how do I pass the values of the variables in function getValues() to function lookUps() ? Using the global declaration doesn't work. Note: the "echo" commands in functions loop0(), getValues(), and lookUps() are there for debugging. The results of the echo commands tell me where things are working correctly - or not. The script: <?php /* -- compare nslookup for hostname & ip address -- */ // -----begin vars ----------- $dir = "."; // folder for input and results files $thisDay = date("Ymd"); // date used in file names ex: 20100316 $fileIn = $thisDay . "-panda.txt"; // input file $fileOut = $thisDay . "-results.txt"; // results file $handleIn = fopen($fileIn, 'r'); // open input file read-only $textA = " - computers without Panda\n"; // part of header line in results page $textB = $thisDay.$textA; // -----end vars ------------ // ----- begin functions ------------- function finis() // the last step in the script { global $fileIn; global $fileOut; close ($fileIn); close ($fileOut); exit(); } function openFileOut() // create log file { global $fileOut; global $textB; fopen($fileOut, 'w'); // open the output file for write fwrite($fileOut, $textB); // print header line at top of results page } // leave results page open for more writes function openFileIn() // open input file (text) { global $fileIn; fopen($fileIn,'r'); // open the input file for read } /* --- example of values in function getValues() $data = OHE-CL30,10.11.1.59 $z = 19 // count of chars in entire line $b = 8 // location of comma $a = 0,7 "OHE-CL30" // 1st substring in $data $c = 9,18 "10.11.1.59" // 2nd substring in $data --- end example -------------- */ function getValues() { global $handleIn; $data=fgets($handleIn); // the string being read // example: OHE-CL30,10.11.1.59 // each line of input file resembles this: // hostname,ip address $z = strlen($data); // how many chars in entire line // example: 19 $b = strpos($data,","); // find the comma // example: 8 $a = substr($data,0,($b-1)); // hostname // example: 0,7 "OHE-CL30" $c = substr($data,($b+1),($z - 1)); // ip address // example: 9,18 "10.11.1.59" // used for debugging; it shows that this function works as expected // $m = ", "; // echo $data . $z . $m . $b . $m . $a . $m . $c . "\n"; } function lookUps() // compare and reverse compare IPs & HOSTNAMES { global $a; global $c; global $fileOut; // echo "a = " . $a . ", c = " . $c . ", logfile = " . $fileOut . "\n"; // for debugging $aa = "nslookup" . $a . " >> " . $fileOut; $cc = "nslookup" . $c . " >> " . $fileOut; shell_exec($aa); shell_exec($cc); // exec($aa); // exec($aa); // passthru($aa); // passthru($cc); } function loop0() { global $handleIn; $counter=1; while (!feof($handleIn)) { getValues(); // echo $counter . "\n"; // testing for progress of the loop $counter++; lookUps(); } } // ----- end functions ------------- /* ------------ runtime ------------ */ openFileIn(); openFileOut(); loop0(); echo " ======== closing files and going home =========\n"; finis(); ?>
  8. var_dump($DOCUMENT_ROOT,$PHP_SELF,$DOCUMENT_ROOT.$PHP_SELF); throws NULL NULL string(0) ""
  9. When I run either of the code snippets below, the browser returns Page Last Updated: 12.31.1969 /* format of date display */ $fmt_ymd = "m.d.Y"; /* date page was last modified */ $file_last_modified = date(filemtime($_SERVER['SCRIPT_FILENAME'])); /* display foooter */ $last_modified = date($fmt_ymd,$file_last_modified); echo(" Page Last Updated: " . $last_modified); or /* format of date display */ $fmt_ymd = "m.d.Y"; /* date page was last modified */ $file_last_modified = filemtime("$DOCUMENT_ROOT$PHP_SELF"); /* display foooter */ $last_modified = date($fmt_ymd,$file_last_modified); echo(" Page Last Updated: " . $last_modified); Trust me - the page was not last modified 40 years ago. All pages involved were modified today. I get the same results on different servers, one with php 5.2.6, the other with 4.4.4
  10. I wrote (like 10,000,000 others) a script to recursively read and list the contents of directories. However, when I print the results to the screen I want to include the contents of the <title></title> block and/or the first nn words in the <body></body> (somewhat like the results from a search engine). How do I read specific, limited content from an HTML file?
  11. How do I rotate images (or banners...) every n seconds? I use the following code to rotate the images every time the page is loaded. However, I want to rotate the images every n seconds while the page is displayed. <?php /* --------------------------------------------------------------------------------- find all files (in this case images) in a folder and rotate randomly when page is loaded or refreshed note: as written here, all files must be valid images and there can be no sub-folders --------------------------------------------------------------------------------- */ $filenum=0; // initialize counter $pix=array(); // create array $usedir="../images/const/"; // show location of images to rotate if ($handle = opendir($usedir)) // open folder for reading { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { $file=$file++; // increment the counter $pix[]=$file; // select the next element from the array } } closedir($handle); } shuffle($pix); // shuffle the elements of the array $displ1=$pix[1]; // create var to id image to display $displ2=$pix[2]; // damphyno why I did this print // display the randomly-selected image "<img src='" . $usedir.$displ1 . "'><br />\n"; ?> To see the code in action: [*]http://www.maryellenoconnor.com/docs/silks.php [*]Refresh the page, then repeat, repeat ....
  12. The goal is simple: I want to display "August 31, 2009" I RTFMed and tried various date functions. I got inconsistent results, so I did some "sanity check" tests. The results were better, but not completely as expected. Some returned Tuesday, August 18, 2009 15:08:45 Others returned Wednesday, December 31, 2008 00:12:01 <?php // php 5.2 $rightnow=$_SERVER['REQUEST_TIME']; $fmt= "l, F d, Y H:m:s"; // V $thev = mktime(0,0,1,08,31,2009); $dayv = date($fmt,$thev); // returned [b]Wednesday, December 31, 2008 00:12:01[/b] // W $thew = time(00,00,01,08,31,2009); $dayw = date($fmt,$thew); // returned [b]Tuesday, August 18, 2009 15:08:17[/b] (current time) // X $thex = time(); $dayx = date($fmt,$thex); // returned [b]Tuesday, August 18, 2009 15:08:17[/b] -- as expected // Y $dayy = date($fmt,$rightnow); // returned [b]Wednesday, December 31, 1969 16:12:00[/b] (!!!) // Z $dayz = date($fmt); // returned [b]Tuesday, August 18, 2009 15:08:17[/b] -- as expected ?> What is the correct syntax to display August 31,2009
  13. To quote myself (from the original post) "Somewhere in there I've missed a comma or some such stupid error that I can't see." First, an explanation. [*]The part that we have discussed is a small piece of a much larger project. [*]I try to build my code as modular as possible. I break down the big task into smaller tasks. The smaller tasks wind up as small scripts or in some cases, functions. The big task is handled as a 'home' page with a lot of included files. The report procedure was in an include that was included in an include. So the trees got in the way of my seeing the forest (to badly use a metaphor). While pondering replies (all very good, thank you), I realized I had been focused on the lower-level includes. What I had not examined closely: the home page and its first-level includes. The home page had an include that contained the query around which everything else is built. The person who requested this report did not want 'room' or 'fax' to appear. Mistake #1 was to remove those fields from the original query - instead of omitting them from the report. Mistake #2 was forgetting that that I removed them way up near the top level. When I looked at the original query way up there on the home page, clear as could be was the answer AND my comment about why those fields were omitted. du-oh! So I put 'room' and 'fax' back into the original query (and fixed the comment) ... and this report works! Thank you all. I learned a bunch of good stuff. And I got a concussion and waffle-like imprints on my face - from beating my head on the keyboard. :facepalm: The good news: the lady for whom I write a lot of stuff usually sends over something chocolate as appreciation for my work. I can hardly wait!
  14. Number of rows : 914 Number of rows where room !="" : 747 Number of rows where room ="" : 167 Number of rows where room IS NULL: 0 Number of rows where FAX !="" : 58 Number of rows where FAX ="" : 0 Number of rows where room IS NULL: 856 However, none of those values impact the results of the mysql_fetch_array. In the report based on the result set for mysql_fetch_array, all rows come up empty for room and fax.
×
×
  • 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.