Jump to content

Conjurer

Members
  • Posts

    107
  • Joined

  • Last visited

    Never

Everything posted by Conjurer

  1. I have an existing directory with about 400 member records in a MySql database The club assistant kept a copy in Excel, and made updates over the last couple years to that one. So now I am trying to synchronize them, and reformat the club one so I can import it into the existing MySQL database. So in MySQL every member was assigned an auto created primary key of user_id like 1001, 1002, 1003, etc. I exported the MySQL directory to Excel worksheet. Then I used a look up where I could to match up the club record with the user_id. Some in MySQL have expired and not renewed, some in club are totally new. So I added the user_id for the club records that exist in the MySql database. The assumption now is that if there is a difference in data for a given user_id, that the club record is more current information and the MySQL record should be updated to the new info. So I now have this all set to go but in Excel. And I am trying to figure out the best way to move it into the MySQL adding the new members and updating any data changes on the existing members. Does that make sense>?
  2. Coming from an Excel Spreadsheet Which I have had to do a bit of cleanup on - i.e. someone used all caps on everything and I have converted to Proper, etc.
  3. That was just for illustration It is a member directory - so I have existing members where last name might have changed, first name might be different (Robert vs. Bob), lot of addresses and phone numbers have changed. So if it is a member 1004 and the phone number changed I want it to update that record. Member 1005 maybe got married and needs to change last name. Member 1006 maybe no changes at all except to mark the 2008 dues as paid, member 1007 changed place of work so the Organization field needs to be changed and the work number needs to change. etc.
  4. Maybe I could use Replace. I just found a reference to that.
  5. I have a database with a number for member records. Names, addresses, phone numbers, etc. Each record was created with a user_id which was an autogenerated number and is the unique index for the table. So now I have received a list with updates to some of these records. I basically want to go in to each record based on the user_id and change each column value for the record if the new value is different than the old one. That is pretty easy to do for one record using the Update table set col1=xyz col2=xyz etc where user_id = 1001 But with several hundred records to update that is pretty cumbersome having to add the column labels for each row. Is there and easy way to do this? If I were to delete the rows where user_id in (list of user_ids) can I then insert the original user_id with the replacement rows? Would I need to turn the key off or something in order to do that? Thanks
  6. I am trying to pass a variable out of a function and reuse it in the page code. On the web page they see I would like to report to them the email value that is in the database and since that is pulled in the first part of the function I thought maybe I could just put some lines in the html using the $email variable, but when I do it gives me an error message of Undefined variable: email Is there a way I can keep the variable live outside of the functions so I can reuse it instead of having to look up the value again? Here is the code where I am trying to access it: $username = $_POST['username']; echo 'This is the username you submitted: ' .$username .'<br>'; try { $password = reset_password($username); notify_password($username, $password); <<<This is the function that finds the email I am trying to pass echo "Your new password has been e-mailed to you at [b]$email[/b].<br />"; echo "If you no longer have access to the [b]$email [/b]e-mail account, please contact our webmaster at info@mydomain.com for assistance.<br />"; echo ' <div id="nav"><a href="http://www.mydomain.com/">mydomain Home</a> <a href="index.php5">Logout</a></div>'; } catch (Exception $e) { echo 'Your password could not be reset - please try again later.'; echo $e; //added to see error } And here is the function that looks up the email address I want to pass into the rest of the web page: //--------------------------------------------------------------------------- // function to notify user of new password //--------------------------------------------------------------------------- function notify_password($username, $password) // notify the user that their password has been changed { $conn = db_connect(); $result = $conn->query("select email from directory where user_id=(select user_id from users where username = '$username')");[/b] if (!$result) { throw new Exception('Could not find email address.'); } else if ($result->num_rows==0) { throw new Exception('Could not find email address.'); // username not in db } else { $row = $result->fetch_object(); $email = $row->email; $from = "From: support@mydomain.com \r\n"; $mesg = "Your password for the directory has been changed. \r\n" ."You can login to the membership directory at http://www.mydomain.com/Directory/index.php5 \r\n\r\n" ."Your username is: $username \r\n" ."Your new password is: $password\r\n\r\n" ."You can either keep this password or change it to one you preferr the next time you log in. " ."To change it, once you log in click on the \"Change Password\" button.\r\n"; if (mail($email, 'Mydomain login information', $mesg, $from)) return true; else throw new Exception('Could not send email. Please contact info@mydomain.com for assistance!'); } } Any ideas would be greatly appreciated.
  7. I guess it is loading automatically. I looked at processes and it is already running and working. Think I am good to go!
  8. I tried changing those to make the root "c:/web site" And now I get an error message when I try to start Apache: OS 10048 Only one useage of each socket address <protocol/network address/port> is normally permitted. :make_sock: could not bind to address 0.0.0.0:80 no listening sockets available, shutting down Unable to open logs
  9. I used to have 2.0 installed but lost my hard disk in a crash. So I just loaded apache_2.2.6-win32-x86-no_ssl.msi and it loaded - I went to the C:/Program Files/Apache Software Foundation/Apache2.2/htdocs folders and the index.html opens and says It Worked. My old 2.0 was set up with a "localhost" directory and I would specify that in my website definitions in Dreamweaver to get my sites to interact with it as a testing server. I am confused with the flollowing settings - do I need to change some of these? Can I change document root to be my webfolder like c:\websites\?:
  10. Wow - thanks for catching that. So what version should I want? What are the differences between these and what is the normal one to choose? I am mainly just using it for web site development to test on localhost before moving to the actual web host server. Want to be running PHP5 and MySQL. Do I want openssl or no-ssl and which version? What is the PGP signature about? Not sure which to choose: apache_2.0.59-win32-x86-no_ssl.msi 27-Jul-2006 19:08 4.2M MSI Installer Package [sIG] apache_2.0.59-win32-x86-no_ssl.msi.asc 27-Jul-2006 19:08 1k PGP signature [MSI] apache_2.0.59-win32-x86-openssl-0.9.7j.msi 29-Aug-2006 22:55 4.8M MSI Installer Package [sIG] apache_2.0.59-win32-x86-openssl-0.9.7j.msi.asc 29-Aug-2006 22:55 1k PGP signature[MSI] apache_2.0.61-win32-x86-no_ssl.msi 20-Sep-2007 00:34 4.2M MSI Installer Package [sIG] apache_2.0.61-win32-x86-no_ssl.msi.asc 20-Sep-2007 00:23 1k PGP signature[MSI] apache_2.0.61-win32-x86-openssl-0.9.7m.msi 20-Sep-2007 00:36 4.7M MSI Installer Package[sIG] apache_2.0.61-win32-x86-openssl-0.9.7m.msi.asc 20-Sep-2007 00:23 1k PGP signature[MSI] apache_2.2.4-win32-x86-no_ssl.msi 10-Jan-2007 03:27 4.2M MSI Installer Package[sIG] apache_2.2.4-win32-x86-no_ssl.msi.asc 10-Jan-2007 03:27 1k PGP signature[MSI] apache_2.2.4-win32-x86-openssl-0.9.8d.msi 10-Jan-2007 03:32 4.9M MSI Installer Package[sIG] apache_2.2.4-win32-x86-openssl-0.9.8d.msi.asc 10-Jan-2007 03:32 1k PGP signature[MSI] apache_2.2.6-win32-x86-no_ssl.msi 20-Sep-2007 00:37 4.1M MSI Installer Package[sIG] apache_2.2.6-win32-x86-no_ssl.msi.asc 20-Sep-2007 00:23 1k PGP signature[MSI] apache_2.2.6-win32-x86-openssl-0.9.8e.msi 20-Sep-2007 00:39 4.7M MSI Installer Package[sIG] apache_2.2.6-win32-x86-openssl-0.9.8e.msi.asc 20-Sep-2007 00:23 1k PGP signature Thanks for the help folks.
  11. I think I got it: Win32 Source: httpd-2.2.6-win32-src-r2.zip [PGP] [MD5] Is that what I want to download/Install. I am not sure what you mean about the port as I am not running IIS
  12. I went over to Apache and tried to figure out what to download from the Mirror site but I am lost. I want to set up localhost Apache services on a WinXP Pro installation. I do not have IIS running. I had Apache 2.0 setup before, but my system crashed and burned. What do I need to download now to get an Apache install? Thanks!
  13. Ok Thanks - I will get the download and go that route. Thanks for letting me know the registry piece.
  14. Not Really - I already had it setup and running before the crash, I copied all those files and directories back - and I think I only have to find my config files to get it back the way it was... Just not sure what file that would be.
  15. My hard disk crashed and burned... So new hard drive - trying to restore my Apache2 program files. I copied everything over - I can see the Apache Monitor and load that but I don't get the option to start Apache. Isn't there a config file that was out in the windows directory that I will need to also copy? Anyone know what file it is?
  16. I have a folder that contains some various images in jpg, gif, etc format. I want to load the file names into an array so that I can then use them in a random generator to change images when the page refreshes. How would I get the filenames into an array? I have used a script to generate the images randomly as follows: PHP Code: <?php $picturesArray = array("trip_1.jpg", "trip_2.jpg", "trip_5.jpg", "trip_6.jpg", "trip_8.jpg", "trip_9.jpg", "trip_12.jpg","trip_13.jpg", "trip_14.jpg","trip_15.jpg"); srand((float) microtime() * 10000000); shuffle($picturesArray); echo "<img src=\"../../assets/images/Deschutes/$picturesArray[0]\""; echo " alt=\"Deschutes River, Oregon\" >"; ?> But with this I have to save all the files as trip_1.jpg, trip_2.jpg, etc. I would like to modify this so I could create the $picturesArray based on the filenames in the directory I want to access, then do the shuffle to mix them up, then echo out the one to show. Any thoughts?
  17. Bingo! ALTER TABLE table_name  AUTO_INCREMENT =1001  << or whatever value you want it to start with. :D
  18. Actually I acknowledged the point when I said I was being annal retentive and that where it starts makes no difference to the database, so that said, how do you do it? I know there is a way...
  19. Currently, to generate a table row from my query I am using: [code]foreach($row as $val)           {             echo "<td>$val</td>";           }         echo "</tr>\n";[/code] That works great as long as I don't have too many columns in the query, but once it gets larger then it causes the output to scroll horizontally and messes up my page layout. I am wondering how I could change this - basically if I know I am querying on 15 columns but can only fit about seven columns how could I fix this to put a "</tr><tr><td>Continued</td>" in between value 7 and value 8? Do I need to do an i counter and increment it or what? If so what am I counting? Here is the more complete code I use now: [code]while ($row = mysqli_fetch_assoc($result))       {         if (!$heading) //only do if header row hasn't been output yet         {           $heading = TRUE; //so we only do this once             echo "<table>\n<tr>\n";             foreach ($row as $key =>$val)               {               echo "<th>$key</th>";               }               echo "</tr>\n";         }                  if ($style=="odd") //set rows as even and odd             $style = "even";           else             $style = "odd";             echo "<tr class=\"$style\">";               foreach($row as $val)           {             echo "<td>$val</td>";           }         echo "</tr>\n";               }//close while     echo "</table>\n"; } [/code] Thoughts or suggestions? Thanks!
  20. Wow - that is exactly the same exact question I have. Call me annal retentive, but when I originally built the table I had a way to do it that set it to 1001 as the starting point. Because it is our member list I would like to have the new data load starting with 1001. It is an AR thing I know because from the functioning of the database it makes absolutely no difference. But it is something I want to do, so what would be the SQL statement to do it? I tried [quote]ALTER TABLE directory MODIFY user_id AUTO_INCREMENT = '1001'[/quote] But that bombs - I am trying to modify it in PHPAdmin.
  21. [b]Bingo![/b] Turns out get_random_word is a defined function in another part of the includes and it is looking for a dictionary to pull the word from. Now I just need to find the dictionary.  But I would mark this resolved, if I knew how.  ::)
  22. I echoed out the $e error variable and get the following: [quote]'Exception' with message 'Could not generate new password.' in /home/consult/public_html/development/Testing/26/user_auth_fns.php5:124 Stack trace: #0 /home/consult/public_html/development/Testing/26/forgot_passwd.php5(10): reset_password('Houdini') #1 {main}[/quote] Does that mean line 124 of user_auth_fns is where the error happened?  If so that would be where it tried to get a random dictionary word b/w 6 and 13 chars in length for the new password. Is this dictionary function maybe not loaded? If so, how would I find out, how would I load, or what is another approach here to generate a random password? So much to learn, so little time!  ::) function reset_password($username) [code] 116 function reset_password($username) 117 // set password for username to a random value 118 // return the new password or false on failure 119 { 120   // get a random dictionary word b/w 6 and 13 chars in length 121   $new_password = get_random_word(6, 13); 122   123   if($new_password==false) 124     throw new Exception('Could not generate new password.');  // <<<<<<<<<<<<Error Line!?? 125   // add a number  between 0 and 999 to it 126   // to make it a slightly better password 127   srand ((double) microtime() * 1000000); 128   $rand_number = rand(0, 999); 129   $new_password .= $rand_number; [/code]
  23. I pulled together the pieces that are trying to run but not working.  See Code below.  Problem is I have no way to tell where it is bombing.  When I click the link for forgot password I get the forgot password form, fill in the username for the test user and then I get two lines back: This is the username you sent: Houdini Your password could not be reset - please try again later. And then a  link back to the login form. It seems to be jumping to the following piece of code: [quote]  catch (Exception $e)   {     echo 'Your password could not be reset - please try again later.';   } [/quote] How can I add some error checking things in the reset_password() function to help me make sure this part is working and see what is happening? Thanks! [code] <?php   require_once("bookmark_fns.php5");   do_html_header("Resetting password"); //called from output_fns   // creating short variable name   $username = $_POST['username']; echo 'This is the username you sent: ' .$username .'<br>'; // added by me for debugging   try   {     $password = reset_password($username); //called from user_auth_fns.php5 -see below     notify_password($username, $password); //called from user_auth_fns.php5 -see below     echo 'Your new password has been emailed to you.<br />';   }   catch (Exception $e)   {     echo 'Your password could not be reset - please try again later.';   }   do_html_url('login.php5', 'Login'); //called from output_fns - jsut wraps Url in in href tag     do_html_footer(); //called from output_fns - just closes body and html tag. ?> Here are the relevent called functions: // bookmark_fns.php5   require_once('data_valid_fns.php5');   require_once('db_fns.php5');   require_once('user_auth_fns.php5');   require_once('output_fns.php5');   require_once('url_fns.php5'); // functions from user_auth_fns.php5 function reset_password($username) // set password for username to a random value // return the new password or false on failure {   // get a random dictionary word b/w 6 and 13 chars in length   $new_password = get_random_word(6, 13);     if($new_password==false)     throw new Exception('Could not generate new password.');   // add a number  between 0 and 999 to it   // to make it a slightly better password   srand ((double) microtime() * 1000000);   $rand_number = rand(0, 999);   $new_password .= $rand_number;   // set user's password to this in database or return false   $conn = db_connect();   $result = $conn->query( "update user                           set passwd = sha1('$new_password')                           where username = '$username'");   if (!$result)     throw new Exception('Could not change password.');  // not changed   else     return $new_password;  // changed successfully  } function notify_password($username, $password) // notify the user that their password has been changed {     $conn = db_connect();     $result = $conn->query("select email from user                             where username='$username'");     if (!$result)     {       throw new Exception('Could not find email address.');      }     else if ($result->num_rows==0)     {       throw new Exception('Could not find email address.');  // username not in db     }     else     {       $row = $result->fetch_object();       $email = $row->email;       $from = "From: support@phpbookmark \r\n";       $mesg = "Your PHPBookmark password has been changed to $password \r\n"               ."Please change it next time you log in. \r\n";                   if (mail($email, 'PHPBookmark login information', $mesg, $from))         return true;            else         throw new Exception('Could not send email.');     } } [/code]
  24. Well it is supposed to work like Redarrow said, they enter the user name, it creates a new password in SHA1 format and mails to their email. But it isn't creating the password. I will try to piece together the functions and then post it here. Will take a bit. Thanks!
×
×
  • 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.