DavidAM
Staff Alumni-
Posts
1,984 -
Joined
-
Days Won
10
Everything posted by DavidAM
-
That's a lot of work for every single page load. However, 2) Type the address of the rotate.php script into your browser's address field. If it works, you should see the image. If it fails, you might see some error messages. 1) Turn on error reporting: error_reporting(-1); ini_set('display_errors', 1); at the beginning of the script so you can see any errors that are occurring. Fix them all (including warnings and notices!) 3) Check the relative path names you are specifying. For opendir() it is looking relative to the path where the main script that is running right now is located (i.e. rotate.php). For the Location: header, well, the standard says you are supposed to supply a full url -- with the http:// and the domain and the full (web) path to the file. Since you are specifying a relative path, the browser is free to determine what it is relative to when making its request. 4) In the CSS file, you have specified a relative page. I think that is relative to the script that contains the LINK tag that loads the CSS file. A full url would probably be better here as well. #1) When you tell us "its not working" we have absolutely no idea what you mean. Tell us what it does that it should not do, or what it does not do that it should do. Look in the View->Source of your browser and see if there is any non-rendered stuff there.
-
He means "salt" ... md5 is a hash.
-
Store your dates as DATE or DATETIME not as VARCHAR. Then you can use the actual column in the WHERE clause instead of having to do the conversion again.
-
Getting Information From All .txt Files In A Folder
DavidAM replied to Strahd's topic in PHP Coding Help
In his post, glob is a link to the manual where you can read what it does. It will return an array of filenames (you can use wildcards), so then you process each element of the array instead of reading the filename from the command line arguments. You will also need foreach -
Show us this segment of the code with your changes. It should be something like this: $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=UTF-8\r\n"; $headers .= "From: ".$book_full_name." <".$email_to.">" . "\r\n" . "Reply-To: " . $book_email . "\r\n"; # Added CR-LF $headers .= 'Cc: ' . $email_cc . "\r\n"; # ADDED - Use the variable with the CC address # NOTE: You are unconditionally setting $emailSent to TRUE, set it to the return value of mail() $emailSent = mail($email_to, $subject, $body, $headers); #$emailSent = true; REMOVE THIS LINE Also, please tell us what "doesn't work" means. Do you have error reporting turned on at the highest settings? Do you get any errors or warnings? Does the script SAY it worked but the email never arrives? Did you check you Junk Mail and Spam folders?
-
Furthermore, there is no need for the ob*() calls in that code. The RETURNTRANSFER option of curl will return to content and nothing will be output, except possibly errors. The end of that function should be something like this: $data = curl_exec ($login); curl_close ($login); unset($login); return $data; } Although the unset() is completely unnecessary, since the variable immediately falls out of scope.
-
If it is not displaying what you asked it to display, what is it displaying. There's not a lot of room inside the loop for failure. What I do see is that you are retrieving an entry from the filesystem and an entry from the database at the start of each loop iteration. Then you are assuming that the two entries are for the same file or directory. However, since you do not process the current and parent directories ("." & "..") you are discarding two entries from the database (unless those two entries are in the database as well). Personally, I would not depend on the two lists (readdir and the query) to return the same data in the same sequence. I would retrieve one set in an array and then loop through the other set matching to the array.
-
Whats Do You Find Frustrating In A Third Party Script?
DavidAM replied to Hall of Famer's topic in Miscellaneous
Documentation and/or Online Help that just repeats the field label. Form: Port Number: ______ Protocol: _____ Help File: Port Number: Enter the Port Number Protocol: Enter the using Protocol (and stupid grammatical errors) -
Checkboxes are not POSTed unless they are checked. So the "terms_and_conditions" element will not be in the POST array unless the user checked the box. You need to change the IF statement to if (! isset($_POST['terms_and_conditions']))
-
Congratulations! Of course, here in Texas, the party has got to be Big!
-
Actually, it is searching for all files whose name contains the character sequence typed by the user. It could be a single character, or a file extension, or any part of the filename. It lists each file found as a link. The fact that you posted here indicates you are having some kind of problem with the script. However, you have not stated what the problem is. If you tell us what it does that it should NOT do, or what it does NOT do that it SHOULD do; we may be able to provide some help.
-
You would not carry the account_id or affiliate_id in the child table. You would carry the parent table's id (as a foreign key). If I am reading this correctly, the account_id, affiliate_id, created_date and hour columns identify a row, right? I would move the created_date up into the parent record as well. I would also rename it to "summary_date", I assume it represents the date being summarized, not the date the summary record was created. So now your tables look like this: CREATE TABLE accounts_summary_copy ( id int(11) unsigned NOT NULL AUTO_INCREMENT, account_id int(11) DEFAULT NULL, affiliate_id varchar(64) DEFAULT NULL, -- RENAMED FROM created_date TO summary_date summary_date date NOT NULL DEFAULT '0000-00-00', PRIMARY KEY (id) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; CREATE TABLE accounts_summary_child ( id int(11) unsigned NOT NULL AUTO_INCREMENT, -- REMOVED account_id, affiliate_id AND created_date ADDED parent_id INSTEAD parent_id int(11) unsigned NOT NULL, -- CHANGED NAME OF hour COLUMN ALSO CHANGE DATATYPE summary_hour TINYINT UNSIGNED DEFAULT NULL, posted int(11) DEFAULT NULL, posted_time double DEFAULT NULL, accepted int(11) DEFAULT NULL, accepted_time double DEFAULT NULL, errored int(11) DEFAULT NULL, errored_time double DEFAULT NULL, posted_postback int(11) DEFAULT NULL, posted_postback_time double DEFAULT NULL, accepted_postback int(11) DEFAULT NULL, accepted_postback_time double DEFAULT NULL, errored_postback int(11) DEFAULT NULL, errored_postback_time double DEFAULT NULL, sales int(11) DEFAULT NULL, sales_sum_price decimal(10,2) DEFAULT NULL, score int(11) DEFAULT NULL, PRIMARY KEY (id), -- ADD FOREIGN KEY FOREIGN KEY (parent_id) REFERENCES accounts_summary_copy(id) ON UPDATE CASCADE ON DELETE CASCADE, -- CHANGE ALTERNATE KEY SINCE WE REMOVED THE created_date KEY hour_parent (hour,parent_id) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; Note: I never use the backticks for column names. They are only necessary if the column name is a reserved word or otherwise non-standard. I find it best to avoid reserved words (and potential reserved words) for column names as it can create issues later on. You may note that I changed the `hour` column to summary_hour. I'm not sure if HOUR is a reserved word or not, but I think it has potential. The FOREIGN KEY constraint will add an index on parent_id automatically. I'm not sure of the data definition for some of your columns. But concerning the removal of the "calculated" columns. If, for instance, score_avg, can be calculated from the other data in the row, you can safely remove it. If the value is dependent on other rows (say a running average for the day), you may want to leave it in. I would personally, do some testing with live data to determine if I could live with the overhead or not. (And whether or not I could come up with the correct query). You may want additional indexes on the parent table (for account and/or affiliate, and possibly date) it depends on how you intend to query it. [Edit]: I don't have as much experience with OLDP (and summary tables) as I do with OLTP. So, I may be pushing too far towards normalization. Maybe someone else will pop in and confirm or refute my suggestions.
-
Obviously, the staging server is not setup "properly" for the app. Did you create a database for it? Did you put the data in the database? Did you adjust the database credentials? Is the database server available to PHP? Does the Database Username in the app have proper permissions? Is the filesystem setup properly? Does PHP and Apache have the appropriate permissions?
-
Even IF (that's a BIG if) it is necessary to store aggregated data for summaries, it is NOT recommended to store multiple columns of data with the same meaning. If you have to add a sequence number to the name of a column, then you need to split those columns out into a child table. This child table should be keyed by date and hour. Then you can keep as much summary data as you want, and let the queries determine the period being examined. Store only the aggregates, do any calculations possible at query-time. I mean, do not store the average for a given hour, if you can calculate it from other data in the row. There is probably NO advantage to defining a KEY on account_id (in your example) since it is the first field in the composite KEY, you essentially have that index available already.
-
In your first post:   ; is a Non-Breaking SPace. Which means "do not word-wrap here". Since there are no other spaces in your "Paragraph" there is nowhere for the browser to wrap, so the line goes on forever. To fix this, put a space between each of the entries: echo ' <a href="products.php?s=' . (($display * ($i - 1))) . '&p=' . #.....^ That's a space
-
If you are simply trying to protect your users from nefarious (other) users, you may want to look into curl. After verifying that the url is formatted properly, you can use curl to send a HEAD request to the url. If the request fails, either the server is down or the user entered an incorrect or not-active URL. If the request succeeds, the HEAD request sends you all of the headers (but none of the content). Check the Content-Type header to see what kind of data the url sends. You can also look for a Content-Disposition header (which is used to force a download). The Content-Type should be more definitive than the file extension on the link.
-
Single Or Multiple User Login On One Page?
DavidAM replied to justlukeyou's topic in PHP Coding Help
Add a select list or radio buttons on the login form, and have the user choose which system they want to login to. Then have your script check the selection to determine which login process to run and where to direct the user. You could store their selection in a cookie so it is pre-selected the next time they come to your site. By the way, I know several gamers who have both xbox and playstation. -
Single Or Multiple User Login On One Page?
DavidAM replied to justlukeyou's topic in PHP Coding Help
You are getting advice here from professionals; advice that would cost you hundreds of dollars in consulting fees if you hired a consultant. Even if you hired a consultant, you'd get advice from a single person; here you have advice from multiple seasoned professionals who have been there and done that. We are all telling you that the design is going to create problems. Yes, you have the per-group login working. But as you are now experiencing, you want to do something slightly different from what was considered in the design phase, and that task is much more difficult to accomplish because the design faulty. There are two ways to change the design, create a single table with all the columns from all the tables and revise your current code/plans. Yes, this makes a large table, with lots of columns, but so what? that's what databases are for. The other option is to create a user table with all the columns that are common between the three existing tables. Then remove those common columns from the three tables and add a foreign key to the "super users" table. Put a type flag in the "super users" table to indicate which of the three groups the user belongs to. Keep in mind the user could belong to more than one group. Which solution is "correct" for your application is a decision to be made by the design team (you). It will require consideration of a lot of factors that only your design team will have. Consider this: In your current design what happens when you have a user in all three groups; and that user moves. He has to update his address in all three group tables. Or maybe he forgets and only updates one address. How do you know which address is correct? And why should the user have to go to the extra effort to enter the same information (his new address) in three different places? I only have to write the code once; the user has to use it every day. Who should have the easier task? As soon as you get around this obstacle, you will find another similar obstacle which also becomes more difficult because of the database design. -
Need To Make Sql Query Into Hyperlink That Opens New Window
DavidAM replied to klotzdr's topic in PHP Coding Help
... (what Pikachu said, and) most browsers today make it very simple to open a link in a new window (or tab) if that is what the user wants. -
By not telling us what is does that it should not do; or what it does not do that it should do.
-
Create And Download A .zip Archive From A Folder
DavidAM replied to ConfigureWEB's topic in PHP Coding Help
Have a look at the manual page: ziparchive.addemptydir. There are a couple of user comments there with code on how to do that. Basically, in your current code, when "$file" is a directory (is_dir), you have to add an empty directory to the archive, then scan that directory (on the file system) and add all of its files (and directories). -
Now that's chest-thumping! Only in databases that are designed to support loosely-typed languages (like mySql). I have worked with multiple enterprise database engines, that do not support quoting of numeric data-types. Numeric data-types should never be quoted. As Jessica pointed out, have a look at prepared statements. In order to bind a variable to the statement, you have to specify the data-type. It is trivial to add an additional field to whatever method call you have in order to pass the data types along. $fields = array('Name' => 'I. M. Noob', 'Age' => 15); $types = array('s', 'i'); $sql = $db->buildQuery($fields, $types); public function buildQuery($fields, $types) { $sql = 'UPDATE myTable SET'; $ind = 0; $sets = array(); foreach ($fields as $column => $value) { switch($types[$ind++]) { case 's': $sets[] = $column . '="' . $value . '"'; break; case 'i': $sets[] = $column . '=' . $value; break; default: trigger_error('Unknown datatype', E_USER_ERROR); return false; } } $sql .= implode(', ' $sets); return $sql } That's not from my library. I quit using generically generated queries a long time ago. A data model (class) that is specific to a particular table knows what columns exist and what their datatypes are.
-
The "." (dot) will not match a new-line unless you use the "s" modifier on the Regular Exp<b></b>ression. $quote = preg_replace("'<ol>(.*?)<li>'s", '', $quote); // first 2 tags
-
Is It Possible To Add 6 Database To 1 Shopping Cart ?
DavidAM replied to smallc28's topic in Third Party Scripts
Put the hats and accessories into tall square boxes; fold the shirts and jeans and put them into flat boxes; you should put the dresses on hangers, but, if you stack the boxes right, you might be able to lay them across the top. Make sure the dresses don't drag on the floor, I really hate it when my lace gets dirty like that. Sorry, I couldn't resist. You are going to have to provide a whole lot more detail to get any kind of meaningful answer. Best answer is: 4) Don't use multiple databases; and don't say "databases" when you mean "tables". 3) Don't use multiple tables. 2) Yes, anything is possible. 1) Try it and see!!