-
Posts
422 -
Joined
-
Last visited
-
Days Won
1
Everything posted by awjudd
-
First thing I see are all of the public member variables but then you have setters for them. I would make them all private. What happens if I want more than 1 CC / BCC email address? Do I have to make the semi-colon separated list myself? You are also forcing there to be a TO address. What if there isn't (i.e. a mailing list where you don't want to show the members of it so everyone is BCC'd)? You never call the setContentType nor the setCharset functions so they will always be empty. Your send method: - you call $this -> setFromName () twice and then you start cycling through everyone in the TO list ... why are they not all sent to with one email? - if any 1 mail is sent succesfully the $sent flag will be set to TRUE and it will mark it as a success - continue in foreach loop is useless there ... it will just jump up to the beginning of the loop anyways (no other code below it) - if ( $sent = TRUE ) ... you are assigning TRUE to the value so that will always evaluate to true. All you would really need there is return $sent; because it is already either TRUE / FALSE Another small thing I noticed, no comments throughout the code ... especially on those public functions Hope this helps. ~juddster
-
Side Note: since login_date is an INT, you don't need to put the number in quotes. You only need to do that for non-numeric data types. ~juddster
-
So that is about 20 connections for each page that is loaded. If there are 20 people on the site, that is 20 * 20 = 400 connections to your database. This is what I'm guessing the problem is. I would change this object so that it follows the Singleton pattern so that there is ever only 1 instance in existence. ~juddster
-
How many times do you instantiate the connection object in your code? EDIT: Why did you close your other topic saying the *exact* same thing? ~juddster
-
You don't need the LEFT JOIN because it will just slow it down in this case (since you have a condition on the RH table anyways which will kill any NULLs). I would put a FOREIGN KEY (use INNODB because MyISAM doesn't support FKs) constraint on the users_id column so that the optimizer is able to speed that up a bit. But yes, it works. That said, I personally would change the INT for the time to DATETIME. You gain lots of additional functionality and readability of your queries for a few more bytes ... ~juddster
-
But it is now at a different spot ... Looking at the definition for CONCAT (http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_concat) you can give it a number. UPDATE `apartments` SET mainImage = CONCAT(ID-SupplierID-0,'.jpg') WHERE InternalSupplierID=7;
-
You are missing the quotes around your string ... and you have 1 too many quotes at the end ... UPDATE `apartments` SET mainImage = CONCAT(CAST(ID-SupplierID-0 AS VARCHAR(50)),'.jpg') WHERE InternalSupplierID=7;
-
If the result sets are going to be the same, you could make a function and then call that all 4 times just passing in the array coming back from the database. I noticed that you had LIMIT 1 at the end of your query but all of your mysql_fetch_array's are in a while loop ... is this for any particular reason? If you want multiple rows, you should remove the LIMIT 1 from the query and if you want only one row returned, you should remove it from being in a loop since it isn't necessary. That said, you can probably join all 4 of your queries together and with a bit more logic split all of the sections up just by watching the subcategory until it changes ... ~judda
-
php/mysql query help: populate a list based on selected items
awjudd replied to wabash's topic in MySQL Help
Sorry Bill, as Keith mentioned, I had a typo ... it should be intval instead of interval. ~judda -
php/mysql query help: populate a list based on selected items
awjudd replied to wabash's topic in MySQL Help
Your syntax error is actually lower than that ... it is: <?php $sql = "SELECT a.Id, b.Make, a.Price FROM ActualCarsTable a INNER JOIN CarMakeTable b ON a.Make = b.Id WHERE b.Id = ".interval($_REQUEST['make'])"; I removed the ' from around each of the tables in the JOIN. If you want to delimit it somehow, you should be using the backticks (`). $sql = "SELECT a.Id, b.Make, a.Price FROM ActualCarsTable a INNER JOIN CarMakeTable b ON `a`.`Make` = `b`.`Id` WHERE `b.Id` = ".interval($_REQUEST['make'])"; ~judda -
"INSERT command denied to user" -- two connections to two DBs
awjudd replied to stevieontario's topic in MySQL Help
I agree with Pikachu here ... If the host was able to add the information into your table, then they are using a different username and password combination since INSERT is not allowed for your user. ~judda -
Right table = the table on the right hand side of the join. Left table = Submit Right table = select angler, max(length) as mlength from submit group by angler ~judda
-
If you have a 1-many relationship as you do, including the values will expand based on fact that those are different values, therefore making the sets different. You could do a GROUP_CONCAT if you wanted to in order to combine them into one record ... but now I'm not sure what you are trying to do. ~judda
-
I'm guessing that the left join is returning multiple rows. You could either GROUP BY all of the fields or SELECT DISTINCT. Either way will work at killing the duplicates. ~judda
-
I'm guessing that the right table doesn't return the 8 extra rows you were expecting or something along those lines. ~judda
-
I would add two more indices on top of the PRIMARY KEY which was previously mentioned. They are on the following sets: - (story_id, userc, date ) - (story_id, userc ) This should speed up your queries a bit. However it won't be able to help the query with the UPPER and LEFT in it since those values don't have indexes on them. ~judda
-
angler is being returned by both the submit table and the subquery. In order to fix that you just need to qualify the angler which is in the outermost select statement (i.e. dt.angler) ~judda
-
Couldn't you just do it upon retrieval from the database (i.e. in your SELECT query?) ~judda
-
How to take the first letter and insert it in another field
awjudd replied to hoverinc's topic in MySQL Help
DELETE FROM TABLE WHERE catid != 40 There is no such thing as DELETE * FROM ... ~judda -
How to take the first letter and insert it in another field
awjudd replied to hoverinc's topic in MySQL Help
Use mysql's LEFT function (http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_left)? ~judda -
Then fully qualify the field name (table.field) in your returned table? ~judda
-
Have you looked at WordPress? That is the most common blog software out there. ~judda
-
While you are at it ... can you help me download the interwebs?
-
Create Account Site - Is this secure?
awjudd replied to condoravenue's topic in Beta Test Your Stuff!
$_POST[foo] and $_POST['foo'] both work because PHP will automatically upconvert single words of text that it doesn't know as a constant to a string. That said, using $_POST[foo] is slower because not only does it cause notices to be thrown but it has to check for any definitions before it can assume that it is a string. Sample: <?php $arr = array (); for ( $x = 0; $x < 1000000; $x++ ) { $arr [ foo ] = 'bar'; } ?> Time of execution: $ time php test.php real 0m1.641s user 0m1.424s sys 0m0.044s Versus: <?php $arr = array (); for ( $x = 0; $x < 1000000; $x++ ) { $arr [ 'foo' ] = 'bar'; } ?> Run Time: $ time php test.php real 0m0.467s user 0m0.292s sys 0m0.052s Yes, this is a highly exaggerated case but it is a decent example of how it is bad ~judda