-
Posts
16,734 -
Joined
-
Last visited
-
Days Won
9
Everything posted by PFMaBiSmAd
-
Cannot output datetime values from table correctly.
PFMaBiSmAd replied to webmaster1's topic in PHP Coding Help
Just use the mysql DATE_FORMAT() function in your query, that's what it is for. I would also use an alias name so that you can simply reference the results by the alias - $min= $rowmin['alias_name_you_choose']; -
At least one combination/version of operating system, Apache, and php running as an Apache Module has been found to parse files names like something.php.jpg AS php files when they are requested. So, upload validation code that only relies on the ending file extension will allow a .php script file to be uploaded. If that file can then be browsed to and executed by the php language engine, a hacker just took over your web site. The best upload security you can use is to place the uploaded files into a folder where either all http requests have been prevented or where any server side scripting engines have been disabled.
-
The uploads folder does not have the necessary ownership or permissions for the web server to access it. What method did you use to create that folder? If you use a .php script to create the folder, it will have the correct ownership. If you use your hosting control panel it (should) have the necessary ownership. If you used your FTP client, the folder will be owned by the owner that the FTP server is running under.
-
Your target path should be something like - /var/www/vhosts/someplace.com/httpdocs/Documents/uploads/ What you currently have in the code is a folder /someplace.com/.... starting in the root of the current drive, which even if it existed, you likely don't have permission to access.
-
Your function is returning false on the first failed test. Unless the first entry in the array matches the value, you will always return a false value. Your code will be simpler if you use the in_array() function, rather than looping through the array.
-
Another stupid new-guy question (timestamp, elapsed time)
PFMaBiSmAd replied to cmattoon's topic in PHP Coding Help
Mysql has a couple of dozen built in data/time functions that you can use to do just about anything with a DATE or DATETIME value. No slow parsed, tokenized, interpreted php code is needed for most things. You can convert your exiting data into a DATETIME by using the mysql STR_TO_DATE() function in a query. You can also retrieve a DATETIME in any format using the msyql DATE_FORMAT() function in your queries. -
Did you satisfy this - And did you do this so that you can see if what was produced matched the examples in the mysql documentation -
-
You mean from the same folks that thought that what magic_quotes did was a good idea?
-
Your or die() statement does not have the () around the argument.
-
String data must be enclosed in single-quotes so that it is treated as a string and not as a mysql identifier or keyword. Also, back-tacks `` are mysql specific and should be avoided (there is nothing in your query that needs them.) SELECT * FROM oglasi WHERE predmet = 'Bas'
-
Define: "but it just won't work" That could mean a dozen different things and be caused by almost an infinite number of different coding. Due to its' general purpose nature, there is not a "one symptom" only has "one cause" relation ship. No one can tell you what is causing your code to "but it just won't work" without seeing your code and knowing exactly what symptom you saw in front of you that makes you think that it is not working.
-
You use session_start() and set and reference $_SESSION['....'] variables. session_register, session_is_registered, and session_unregister() were depreciated in php4.2 when register_globals were turned off by default, finally throw a depreciated error in php5.3, and have been completely removed in php6.
-
http://dev.mysql.com/doc/refman/5.0/en/comparison-operators.html#function_in
-
http://www.php.net/docs.php
-
Ref: http://www.phpfreaks.com/page/rules-and-terms-of-service
-
What mySQL??
-
Show user errors on the web page when requiered fields are empty
PFMaBiSmAd replied to kapz22's topic in PHP Coding Help
An assignment statement will always create a variable if it does not already exist, even if NULL is used as the value. Using logic like $errors['first_name'] = (empty($_POST['firstName']) ? 'Please enter a name.' : ''); will always create the array entry. To keep it simple and avoid adding extra logic to test if the errors array is actually empty, you will need to use an actual if(){} statement - if(empty($_POST['first_name'])){ $errors['firstName'] = 'Please enter a name.'; } -
If the formats on both sides of the comparison are identical (and with two digit month and day values) you can compare dates that way (as long as format has the year is first, followed by the month, then the day.) However, a mysql DATETIME is not that exact format, so what you posted would not work.
-
Show user errors on the web page when requiered fields are empty
PFMaBiSmAd replied to kapz22's topic in PHP Coding Help
The code you posted is doing what the logic in it says to do. It echoes Please enter a name. when you don't put anything in the email field (which I'll assume is logically that way just because you are trying get anything to work at this point.) You do have a problem with your setting of the $errors elements. You are setting them to an empty string when there is no error. This however will cause if(!$errors){ to always skip the database query code. Don't set the $errors element at all if the validation test passes. -
Show user errors on the web page when requiered fields are empty
PFMaBiSmAd replied to kapz22's topic in PHP Coding Help
Your form is probably not submitting the data you think it is or you have some other logic error in your code. You are having a page-wide problem. It would take seeing the code on that page to be able to help with what it is or is not doing. -
Should work - SELECT * FROM ".PREFIX."cup_matches WHERE (clan1='$getteam' OR clan2='$getteam') AND clan1 != '0' AND clan2 != '0' AND clan1 != '2147483647' AND clan2 != '2147483647'
-
There is no such thing. You either match row(s) or you don't. If you match a row(s), you get the data values that are stored in those row(s). If you don't match any rows, you get no data at all. It is most likely that your user_pwd column is not large enough to hold a md5 value. Have you looked directly in your database table to make sure that there is a row(s) that exactly matches the values that are in $emailSend and $md5pass?
-
The script worked for me. All I did after copying all the files into a folder in my document root folder was to execute the site.sql file to set up the database, edit the site.xml file with the database details, and change some of the lazy-way short open tags into normal opening tags (the raw php code was being displayed instead of being parsed as code.)
-
Header error but no space or output sent, what to do?
PFMaBiSmAd replied to budder's topic in PHP Coding Help
A) Put the include() statement on the second line of the main file (i.e. the opening php tag is on the first line by itself) so that you can determine if the output is occurring before the <?php tag or due to the include() statement. B) If the error still indicates that output is on line one, then the problem is the BOM (Byte Order Mark) characters at the start of the file like JAY6390 has mentioned twice. C) You need an exit; statement after your header() redirect to prevent the remainder of the code on the 'protected' pages from being executed. All a hacker needs to do is ignore the header redirect and he can still visit each page the same as if the security check code was not even there. -
Blank php pages are either due to fatal parse errors, fatal runtime errors, or simply code that is not outputting anything. Adding the two lines that set error_reporting/display_errors in the code does not do anything in the case of fatal parse errors because the code is never executed to change those settings. You probably introduced a syntax error (fatal parse error) that is preventing the code from ever executing. You could set the error_reporting/display_errors settings in a local php.ini (when php is running as a CGI application) or in a .htaccess file (when php is running as an Apache Module), but frankly, you should be developing and debugging your code on a local development system and only put it onto a live server once it is completely working. It would certainly help if you provided a link to the site where you obtained the script.