Psycho
Moderators-
Posts
12,157 -
Joined
-
Last visited
-
Days Won
129
Everything posted by Psycho
-
That is completely up to you. It all depends on what information you are really trying to convey. Do you want to only show the number of views by unique users or for every view by every user? If the view count has any importance that users might be interested in then you might want to use views by unique users. Otherwise, users will try to "game" the system by refreshing the pages with the records for which they want to drive up the view counts.
-
What I showed was a use of Media Types. Media Queries is a feature to extend the functionality of Media Types. As I understand it, Media Queries can be used to apply different styles based upon specific attributes of the output device. For example, you could have a specific style sheet when the output is Color vs. Black & White (most relevant to print output I would suppose.). You could also have different outputs based upon the resolution of the output device. This is probably one of the biggest advantage. Media Types allows for type called "handheld", but that was defined many years ago before the proliferation of "handheld" devices (of varying sizes ) we have today. There isn't always a one-size-fits-all approach for "handheld" devices. The output that works best for a large tablet won't work well for a smartphone. Then you have the in-between sizes such as the iPad mini. Based on this page (http://caniuse.com/css-mediaqueries) Media Queries are just now supported in all major browsers whereas Media Types have been around for about a decade. I wasn't even aware of Media Queries. I think I'm going to have to play around with those.
-
You could do that, but there is a more elegant option. You can define styles to be different based upon he output. So, you can set the "print" display property of the button to be none when the page is printed vs. in-line when it is viewed in the browser. Put the content in a div (with a class, e.g. 'printDiv') and use some CSS like this: @media print { .printDiv { display: none; } } The content will be displayed in the browser but not in the print output - you can test using Print Preview in your browser.
-
Also, unless the values are integers, you need to enclose them in quotes for the query $LABELNAM = $_POST['LABELNAM']; $LABELCOD = $_POST['LABELCOD']; $query = "UPDATE LABE SET LABELNAM = '$LABELNAME' WHERE LABELCOD = '$LABELCOD' "; $result = mysql_query($SQLLABEL, $CON); if(!$result) { die("Query: $query<br>Error: " . mysql_error()); } No it shouldn't.You are thinking of mysqli_query()
-
Have you verified that you are passing the id on the query string (which you are using in the WHERE clause)?
-
There are ways to try and force the browser to remember the data in form fields when clicking the back button, but I'm too lazy to look it up and there is a much better way to solve this. When I have a form where validation is needed, I submit the form to itself and do the validation. If validation fails I display the error message AND display the form populating the fields with the previously submitted values. If validation passes, then include the page to process the submitted values.
-
Another solution would be to use only ONE possible parameter and use a value on that parameter.= for differentiating the output to display switch($_POST['page_type']) { case 'video': //VIDEO TITLE $title="page title"; //VIDEO URL $url='url details here'; //VIDEO DESCRIPTION $desc="video description here"; //HEADER $header="more video description here"; case 'audio': //AUDIO TITLE $title="page title"; //AUDIO URL $url='url details here'; //AUDIO DESCRIPTION $desc="audio description here"; //HEADER $header="more audio description here"; default: $header="No content found here"; break; }
-
IF the number of fields is consistent (which your sample data contradicts) then I completely agree with requinix: use explode() and array_chunk(). If however, the data is not consistent, then you can still use explode and then loop through the values. Then just detect when a value is not a "yes" or "no".
-
I agree with requinix regarding the use of variables. Makes your code more readable and easier to modify. If you hard code a minimum file size and have to use it multiple times it would be easy to try and change that minimum size and miss one of the instances. My take: $validFileTypes = array('audio/mp3', 'audio/wav', 'audio/mpeg'); $fileType = $_FILES["fileToUpload"]["type"]; $fileSize = $_FILES["fileToUpload"]["size"]; $minFileSize = 26214400; $maxFileSize = 70000000; if( in_array($fileType, $validFileTypes) && $fileSize >= $minFileSize && $fileSize <= $maxFileSize ) { //Conditions passed }
-
To elaborate on what Barand provided, the problem was that the code was creating invalid HTML code. If the value from the DB was 'FOO' the option tag would have been created like this <option value=.FOO.</option> Instead it should be like this: <option value="FOO">FOO</option> which is what Barand's snippet will resolve. But, I would add that I would add a \n at the end of every line of HTML code (within double quotes) so it will put line-breaks in the HTML output. Otherwise, it becomes very difficult to debug the HTML.
-
how to determine file type by content not extension
Psycho replied to maxwel's topic in PHP Coding Help
How about finfo_file() which can return, among other things, the mime type of the file. -
Not technically true. ANDs and ORs are executed left to right - assuming there are no parenthetical conditions. EDIT: But, in a way, the nature of AND does make that true based upon the end result. But, ANDs aren't processed before ORs Here are all the possible combinations using that example: if(true || true && true) { echo "A"; } if(true || true && false) { echo "B"; } if(true || false && true) { echo "C"; } if(true || false && false) { echo "D"; } if(false || true && true) { echo "E"; } if(false || true && false) { echo "F"; } if(false || false && true) { echo "G"; } if(false || false && false) { echo "H"; } The output will be ABCDE. ABCD are true for the lone fact that "a" is true. Once the parser sees that the first condition is true and there is an OR condition it exits the condition check entirely and doesn't check b & c at all. It's easy to verify this function test($bool) { echo "X"; return $bool; } if(test(true) || test(true) && test(true)) { echo "A<br>"; } //Output: XA //Exits after the first condition check if(test(false) || test(true) && test(true)) { echo "E<br>"; } //Output: XXXE //Has to check all three conditions That is why you can use an isset() check for a POST var to prevent warning messages //This will produce a warning if 'foo' is not set if($_POST['foo'] == 'bar') { echo "bar"; } //This will NOT produce a warning if 'foo' is not set because it //will exist after the first false due to the AND condition if(isset($_POST['foo']) && $_POST['foo'] == 'bar') { echo "bar"; }
-
Yes, you would need get an external OCR (Optical Character Recognition) component and call that from within PHP. I don't believe there is any OCR readers built to be run just within PHP.
-
Just from my personal opinion: Font is too big. Don't be afraid of white space - it can make the presentation more appealing. I would also change the actual font used. The content looks too much like a "default" font for my taste. And the title/navigation font has a very thin serif. It may look odd on some displays (again, just my opinion) Be sure to check your site in different browsers. The Submit button isn't displayed correctly in my version of IE Aside from that, I don't see much to comment on. However, I did notice that when clicking the submit button I got an error about "First Name" being required. That tells me you stop error checking as soon as you find the first error. I think it's a better idea to check all the data and then provide the user with a list of all the errors.
-
As far as professionalism, I would suggest taking a second look at the content of the text you are using. A few things stand out to me: . . . as opposed to 50% free estimates? All caps is not appropriate. But, there are many grammatical errors on your main page. I would suggest having someone proofread anything before you put it up. A potential customer could dismiss you right off just from a typo or two reasoning that if you don't pay close enough attention to that what would you miss on their project. Here are a couple others that jump out to me: Clients should be plural possessive: Clients' (apostrophe at the end) Because you have a list of items separated by commas, you can't use a comma after the prefatory part of the sentence - use a colon: I get to work with a few of my favorite things: people, computers, and design.
-
And that is why your question is not accurate. Although the text is "displayed" as basic characters that is not how it is stored within the PDF file. In fact, the characters you see within a PDF may not even be stored as "text" within the PDF. It all depends on how the PDF was created. Without knowing that, there is no way to give you an appropriate answer. If we translate this into an HTML equivalent, the problem is easier to understand. Here are three examples: Example 1: <p>Can't get text</p> Example 2 (Some/all characters escaped) <p>Can't get text</p> Example 3 (Text stored as image - or line art in PDFs) <img src="cantget.jpg" /> Getting the text from the first example would be relatively easy. Getting the text from teh second example would be more difficult and would require a process/function to "know" that the text is transformed and a way to de-transform it. The third example will be very difficult and would require an ORC reader. But, PDFs also have ways to create text on a page using graphical representations of characters. So, "how" the text in the PDF is created is paramount to determining what you need to get the text. If you are dealing with one of the more complicated scenarios you will likely not find a free solution since it would take quite a bit of time and effort to build such a process using PHP only.
-
Whare do you actually execute the query? All I see is the defining of a possible query in which I see one likely problem. The query is defining the ID as the string 'job' for all records. I would suspect that field should be an auto-increment ID field, in which case leave it off of the INSERT query entirely. So, once you execute the query add an or die() to it to see if there are any errors generated. $result = mysql_query($sql) or die("Query: $sql <br>Error: " . myslq_error());
-
You mean the MySQL query, not the "PHP command", correct? You didn't provide any details of the fields in the two tables or what logic should be used to determine that a record from Table A is the same as a record from Table B. Also, based upon your explanation you are wanting to delete the Subscribed user records and leave the un-susbscribed user records - that seems backwards, But, generically speaking, let's say the email address is used to determine that the user records are the same DELETE FROM table_a WHERE user_email IN ( SELECT user_email FROM table_b )
-
Parse error: syntax error, unexpected 'INSERT' (T_STRING)
Psycho replied to dutchman's topic in PHP Coding Help
That function was referenced in your original code, but I don't know what the function is, where it is located, or how it was initiated in your original code. How can I help you? Did you simply copy/past the code I provided and try to execute it? Did you include all the other necessary code from your original script (such as the include file?). The code I provided was only meant to replace the large section of code related to the comment "// Insert plugins". -
how to inclued more then 10 php file .........in a main php.......?
Psycho replied to ShivaGupta's topic in PHP Coding Help
$users = array( 'username1' => 'password1', 'username2' => 'password2', 'username3' => 'password3', 'username4' => 'password4', 'username5' => 'password5' // etc. ); foreach($users as $username => $password) { //Execute same block of code for each username/password } -
How to set file pointer to end of file when opening a file?
Psycho replied to ballhogjoni's topic in PHP Coding Help
fseek() -
how to inclued more then 10 php file .........in a main php.......?
Psycho replied to ShivaGupta's topic in PHP Coding Help
Why don't you explain your problem first? As stated you can include any number of files that you wish. But, sure, here is an example - but I doubt it will help you since you've not explained your problem. //Example of how to include more than 10 files include('file1.php'); include('file2.php'); include('file1.php'); include('file3.php'); include('file4.php'); include('file5.php'); include('file6.php'); include('file7.php'); include('file8.php'); include('file9.php'); include('file10.php'); include('file11.php'); include('file12.php'); include('file13.php'); include('file14.php'); -
Parse error: syntax error, unexpected 'INSERT' (T_STRING)
Psycho replied to dutchman's topic in PHP Coding Help
OK, I didn't see that you were actually executing the query int he if() condition. So, that would be valid. I prefer to execute my queries and assign them to a variable - then check the variable. Gives me more flexibility. Anyway, based upon what I see you repeat the same process seven times only changing the values for the name and code within the queries. So, you can just build an array of those values and write the logic once and just repeat for each pair of values. Also, instead of defining a lot of the values for the INSERT queries, you can define defaults for those fields in the database so you can remove those fields from the SET part of your queries. For example, if 'payment_price" should always default to 0.000 for new records (unless otherwise defined), just set that as the default for the field in the database. Then, when creating a new record you don't have to include that field in the INSERT statement if you want it to have the default value. You would only need to include the field in your INSERT statemetns if you want it to have a value that is not the default. Doing that would greatly clean up the code. But, here is a rewrite that creates a loop to run the same queries with different values that would remove a couple hundred lines of code and maker the script less likely to have errors. $paymentTypes = array( 'iDEAL Checkout - iDEAL' => 'xt_idealcheckoutideal', 'iDEAL Checkout - MisterCash' => 'xt_idealcheckoutmistercash', 'iDEAL Checkout - Direct E-Banking' => 'xt_idealcheckoutdirectebanking', 'iDEAL Checkout - Credit Card' => 'xt_idealcheckoutcreditcard', 'iDEAL Checkout - MiniTix' => 'xt_idealcheckoutminitix', 'iDEAL Checkout - PayPal' => 'xt_idealcheckoutpaypal', 'iDEAL Checkout - PaySafeCard' => 'xt_idealcheckoutpaysafecard' ); // Insert plugins $PREFIX = $aIdealCheckout['database']['prefix']; foreach($paymentTypes as $paymentName => $paymentCode) { $sql = "INSERT INTO `{$PREFIX}plugin_products` SET `plugin_id` = NULL, `name` = '{$paymentName}', `version` = '1.0.0', `description` = 'iDEAL Checkout Gateway', `url` = 'https://www.ideal-checkout.nl', `plugin_status` = '1', `code` = '{$paymentCode}', `type` = 'payment';"; if(!idealcheckout_database_query($sql)) { $query_html .= "<b>Query:</b> {$sql}<br><b>Error:</b> " . idealcheckout_database_error() . "<br><br><br>"; } else { $iPluginId = idealcheckout_database_insert_id(); $sql = "INSERT INTO `{$PREFIX}payment` SET `payment_id` = NULL, `payment_code` = '{$paymentCode}', `payment_dir` = '{$paymentCode}', `payment_icon` = NULL, `payment_tax_class` = '1', `payment_tpl` = NULL, `status` = '1', `sort_order` = '1', `plugin_required` = '0', `plugin_installed = '{$iPluginId}';"; if(!idealcheckout_database_query($sql)) { $query_html .= "<b>Query:</b>{$sql}<br><b>Error:</b> " . idealcheckout_database_error() . "<br><br><br>"; } else { $iPaymentId = idealcheckout_database_insert_id(); $sql = "INSERT INTO `{$PREFIX}payment_description` SET `payment_id` = '{$iPaymentId}', `language_code` = 'nl', `payment_name` = 'iDEAL';"; idealcheckout_database_query($sql); $sql = "INSERT INTO `{$PREFIX}payment_description` SET `payment_id` = '{$iPaymentId}', `language_code` = 'en', `payment_name` = 'iDEAL';"; idealcheckout_database_query($sql); $sql = "INSERT INTO `{$PREFIX}payment_cost` SET `payment_cost_id` = NULL, `payment_id` = '{$iPaymentId}', `payment_geo_zone` = '0', `payment_country_code` = NULL, `payment_type_value_from` = '0.00', `payment_type_value_to` = '0.00', `payment_price` = '0.0000', `payment_cost_discount` = '0', `payment_cost_percent` = '0', `payment_allowed` = '1'"; idealcheckout_database_query($sql); } } } -
Parse error: syntax error, unexpected 'INSERT' (T_STRING)
Psycho replied to dutchman's topic in PHP Coding Help
Hmm, based on the file you provided, I don't see a problem on line 85, but I do see a problem on lines 101, 130, 159, 188, 217 and 246 Line 101 $sql = "INSERT INTO `" . $aIdealCheckout['database']['prefix'] . "payment_cost` SET `payment_cost_id` = NULL, `payment_id` = '" . $iPaymentId . "', `payment_geo_zone` = '0', `payment_country_code` = NULL, `payment_type_value_from` = '0.00', `payment_type_value_to` = '0.00', `payment_price` = '0.0000', `payment_cost_discount` = '0', `payment_cost_percent` = '0', `payment_allowed` = '1'; There needs to be a closing double quote at the end of the strings. Get yourself an editor that does textual highlighting of the code and these errors will be readily apparent. Also, I didn't read through all of that code, but there are plenty of "problems" and it seems to be much more complicated than it should be. For example this: // Insert plugins $sql = "INSERT INTO `" . $aIdealCheckout['database']['prefix'] . "plugin_products` SET `plugin_id` = NULL, `name` = 'iDEAL Checkout - iDEAL', `version` = '1.0.0', `description` = 'iDEAL Checkout Gateway', `url` = 'https://www.ideal-checkout.nl', `plugin_status` = '1', `code` = 'xt_idealcheckoutideal', `type` = 'payment';"; if(idealcheckout_database_query($sql)) { $sql is just a query defined as a string. It isn't executed. So that if() condition will always be true. Also, you appear to be running the same processes over and over with only slight differences. Create a loop or function to run ONE process and change the parameters accordingly. -
retrieve the data in the result set of MySQL using PHP
Psycho replied to matrixinfologics's topic in PHP Coding Help
If you know the basics, you should be able to read the manual to determine that information from yourself. http://www.php.net/manual/en/ref.mysql.php Not sure that anyone here can provide more information that isn't already covered there. Besides, this sounds like a homework question. I wouldn't want to deprive you of a learning experience which, I assume, you are paying for.