[PHP] php 4.2.1 and MySQL
We recently upgraded to php 4.2.1 with Apache and our scripts that access MySQL now fail in mysql_connect().Apache shows the following: Warning: Access denied for user: '[EMAIL PROTECTED]' (Using password: YES) in /var/apache/share/scripts/ais/itweb/projects.php on line 40 Warning: MySQL Connection Failed: Access denied for user: '[EMAIL PROTECTED]' (Using password: YES) in /var/apache/share/scripts/ais/itweb/projects.php on line 40 Sorry... Could not connect to database Not sure why it says it's using password: YES. The call is mysql_connect("host", "fred", "password") as it always has been. I thought that perhaps the function call has changed to include an extra parameter or something, but haven't found anything that says that's true. Can someone tell me what I can do to get these scripts working again? All of my scripts that use MySQL are failing in this same way. Thanks, Brian McLaughlin [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Arrays within classes
This is driving me crazy! I've created a class to hold data so I can just put the object into the session rather than saving off each piece of data separately. But I'm getting odd results from the arrays in my class that I can't explain. Here's a hunk of code that demonstrates: $words; echo "1: words = $t\n";// Shows that $words is empty $this->$words = array(); $t = $this->$words; echo "2: words = $t\n"; // Shows that $words is an array $t = $this->$words["Amy"]; echo "3: words[Amy] = $t\n"; // Shows that $words["Amy"] is also an array -- WHAT?? } }; ### Declare a$ to be an array echo "1: a = $a\n"; // Shows that $a is empty $a = array(); $t = $a; echo "2: a = $t\n"; // Shows that $a is an array $t = $a["Amy"]; echo "3: a[Amy] = $t\n"; // Shows that $a["Amy"] is also empty -- GOOD echo ""; ## Instantiate a test object $test = new test; ?> When I declare a member variable ($words) within the class and then assign to it an empty array, it seems all the elements of that array are also arrays -- they should be empty. When I do the same thing outside of a class ($a), I get the results I expect. Can anyone tell me why that is? Thanks Brian [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Arrays within classes
Hi Erik Thanks for the reply. I'm not sure how I missed the opening { in my message -- I copy/pasted the code. But the opening { is definitely there in the code -- I'd get a nice error message if it weren't. I believe it's OK to have a ; after the class def end-brace, but I removed it and I got the same symptoms. I also believe it's OK to not have the () in the "new test" instance assignment as long as my constructor takes no parameters. I added the (), and didn't get different results. I'm not sure what you mean when you say "Don't you want to perform your error-testing functions on the instances?" I'm trying to initialize some class-arrays in the constructor. I put some echo"" statements in there to try and figure out what was going on. The example is just an example -- the smallest piece of code I could make (presumably) that would exhibit the symptoms. The purpose for the "real" class I'm working with is to encapsulate several arrays (one of which is an array of arrays) along with a few other variables into a data class that can be put/retrieved as a single object into the session. The reason is so that all the code that builds these arrays only happens when the user hits the first page. Then the arrays are available from the session on subsequent hits. My problem is that when I assign an empty array to a variable, I get different results depending on whether that variable is in an object or not. In the case of assigning $a=array(); outside of an object, each element of the array is empty (as I expected). But when assigning $this->$words=array(); results in $this->$words["Amy"] (or any other element for that matter) already being assigned an array. And if I look at the elements of those arrays, they are also initialized to arrays. I don't know how deep it goes. The way I noticed this at first was like this: In the constructor, I'm reading phrases from a file and putting each word into the $words array, and assigning $words[$word]=array($phrasenum); (so each word in the $words array gives back an array containing the id's of the phrases it appears in) When I come across a word that I've already added for phrase 1 in phrase 2, I expect it to already exist in the array, because I put it there the first time I came across the word in phrase 1. Instead, Every element is pre-assigned to another array, and so the code gets confused, thinking that it has entries for any word I care to index the array with. Sorry for the long drawn-out message. Maybe it will help? Thanks Brian "Erik Price" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > I might be completely mistaken here, but it looks like there are a few > errors in your code: > > - No starting brace for the test() method > - semi-colon used after class def end-brace > - no parentheses after "new test" instance assignment > > Don't you want to keep your class as general as possible, and perform > your error-testing functions on the instances? It's hard for me to tell > what kind of data you are trying to represent with this class. My > advice is that, even if it seems unnecessarily didactic, you use some > sort of actual object to help you visualize what you are trying to do > with this class, like Person() or something -- it helps. I can't figure > out what this class is even supposed to do. > > > Erik > > > Erik Price > Web Developer Temp > Media Lab, H.H. Brown > [EMAIL PROTECTED] > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Arrays within classes
Thank you!! Now I need to figure out how to put all this hair back in my head. Brian "Rick Emery" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > I corrected the syntax errors Erik found and added var_dump() after each $t > equation/assignment > > The problem is that you refer to $test->words. You should refer to > $test->words > BIG DIFFERENCE > > $test->words means find the value of $words and look for that variable in > $test. That is, if $words ="abc", > then $test->$words means $test->abc > > Yes, it's in the manual > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] HTML form element
Hi all. I have a tag like this on a php-generated web page. Art Biology Business and Economics" etc. etc. My question is... since this is a multiple-select list, in the php script that this form calls on a submit, how do I determine which options have been selected? If I look at $majors, it is a string whose value is one of the several options that were selected. Thanks, Brian -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php