-
Posts
16,734 -
Joined
-
Last visited
-
Days Won
9
Everything posted by PFMaBiSmAd
-
cant find anything wrong with it but it still throws errors
PFMaBiSmAd replied to Danny620's topic in PHP Coding Help
Variable scope in classes and class methods works exactly the same way as variable scope in functions. Your $dbc variable does not exist inside your class or your class functions unless you pass it in and make it available in the correct scope. I recommend passing $dbc into your class when you create the instance of your class - $new_user = new existences($dbc); Then have your clsss constructor save it into a class variable - private $dbc; function __construct($dbc) { $this->dbc = $dbc; } Then reference it inside of your class methods using $this->dbc syntax. -
You do realize that looping through all the rows in a result set and performing a comparison against each row to find a specific value, using some slow parsed/tokenized/interpreted php code, is going to be at least 10 times slower than letting the database engine find the correct row(s) for you?
-
I'm going to guess that the format you are using for the date is one where the order of the fields making up the date are not, left-right: year, month, day, such as yyyy-mm-dd. You are probably using a format where comparisons work when the dates all have the same year, such as mm/dd/yyyy, but does not work when there is more than one value for year involved. What do your dates look like?
-
We cannot really help you with the mysql error you got unless you post it. Posting the current query would help as well. The GROUP BY term that premiso posted is correct syntax.
-
http://dev.mysql.com/doc/refman/5.1/en/string-functions.html#function_find-in-set Untested but should work - select * from downs where FIND_IN_SET('$user_id',users) Edit: And if you are trying to find if a specific user has permission to download a specific file, you would include the name = comparison in your query - select * from downs where FIND_IN_SET('$user_id',users) AND name = '$the_file_name_that_was_requested'
-
Anything you output after the file data will be appended to the file.
-
Unfortunately, php needs help when array variables are put into a quoted string. I did not expect that you would put the $_POST variables directly into the query (you should be using mysql_real_escape_string() on string data put into a query to prevent sql injection and to prevent special sql characters in the data from breaking the syntax of the query.) You need to surround array variables with braces {} when they are within a string. The problem with your code working on one server and not another is due to register_globals. Register_globals were turned off by default over 7 years ago. Unfortunately (again) it is unlikely you have been programming in php for seven years, so you should not even know how to write code that depends on register_globals. Register_globals have been completely removed in upcoming php6, so now is the time to fix your code to use the correct $_POST, $_GET, $_COOKIE, $_SESSION, and $_SERVER variables where the data is actually coming from.
-
If you have quotes as part of the data, you must escape them before you surround the data in single-quotes that are part of the query syntax. Your function is not protecting against sql injection if you are not escaping the string data.
-
Perhaps if you told us why you were using a function to added quotes to the beginning of a sting and posted the code for that function, someone could see how to help.
-
$rofl = "test,lol"; $moderators = array($rofl); The above code does not create an array that two entries. It creates an array that has one entry with the value "test,lol". If you want or need to start with a comma separated list, use explode to get it into an array.
-
$metode and $search - is there server issue ?
PFMaBiSmAd replied to JTapp's topic in PHP Coding Help
You already have an existing active thread for this problem. Why start another thread? That just looses the history of how you discovered that the two variables are empty. -
Having a problem with a storing a variable to a session
PFMaBiSmAd replied to jim.davidson's topic in PHP Coding Help
Do you have a session_start statement before any output on all pages that set or use a session variable? -
I recommend using some indentation in your source code so that you can see what code is at the same level and where matching {} are at, because the where(){} loop in the loginUser() function is not loop through what you think it is and the logoutUser() and checkUser() functions are currently being defined inside of the loginUser() function. You should also be developing and debugging php code on a system with error_reporting set to E_ALL and display_errors set to ON in your php.ini so that php will help you. Use a phpinfo(); statement to check that these two settings actually get changed after your stop and start your web server in case the php.ini that you are changing is not the one that php is using.
-
You already have one thread for this, that frankly has more information from you posted in it, which has received replies. DON'T start another thread for the same problem. If your first thread is not in the correct forum section, someone will move it for you or you can report it yourself and ask for it to be moved.
-
Copy/paste the lines from the phpinfo output that shows what you see. I suspect you are seeing the mysqlnd driver and not the actual mysql extension. Are you doing this on a system with error_reporting set to E_ALL and display_errors set to ON in your master php.ini (and confirm that the settings are actually those values using a phpinfo() statement in case the php.ini that you are changing is not the one that php is using) so that php WOULD display any errors related to the problem? WHAT is your actual code that is not working? Perhaps it IS doing something out of the ordinary that was required to get it to work on one system but is not the typical/expected method and needs to be adjusted to get it to work on newly installed system that was installed in the expected manner.
-
That's what error reporting helps with the most, things too small to see and easy to overlook.
-
An empty $_FILES['aboutImage']['tmp_name'], since you are checking if the ['error'] element is > 0, could be caused by uploads not being enabled on your server or the size of the uploaded file exceeding the post_max_size setting (the entire $_FILES array will be empty.) For debugging purposes, add the following to the start of your form processing code - ini_set("display_startup_errors", "1"); ini_set("display_errors", "1"); error_reporting(E_ALL); echo "<pre>"; echo "GET:"; print_r($_GET); echo "POST:"; print_r($_POST); echo "FILES:"; print_r($_FILES); echo "</pre>"; What does a phpinfo(); statement show for the file_uploads setting?
-
Actually, upon further review (you must have created this code on a MAC because copy/pasting it results in a mess of tab/new-lines) the two functions I mentioned as a possible cause are present in the source code and aren't the cause of the problem. Your query that is setting $review_result is located after the code that is using $review_result, so yes, the value you are passing mysql_fetch_array() does not exist and is a null value.
-
The code is also using $HTTP_*_VARS. The code is at lest 7 years out of date and should have been updated or removed from distribution long ago. It will take several man-hours by an experienced php programmer to get the script to work. If you don't understand the replies in this thread, you won't be able to correct the code yourself to get it to work on current configurations of php. I recommend finding another script. Here is a more up to date script (but you should convert the short open tags to full open tags) - http://www.evolt.org/PHP-Login-System-with-Admin-Features Edit: when you are evaluating such scripts, please do it on a system with error_reporting set to E_ALL and display_errors set to ON in your php.ini (confirm that these settings actually get changed using a phpinfo() statement) so that php will point out problems it finds as the script is parsed and executed. A long list of php errors will be an indicator that the script is out of date and needs a lot of work to make it functional.
-
Always use a phpinfo() statement to check what settings are in case the php.ini that you are looking at is not the one that php is using. 59 is a ; (semi-colon) unless that is part of a multi-byte encoded character. It would help if you posted the string that corresponds to.
-
The 39 value is a single-quote. That means that the actual data is correct. That either means that your str_replace() code does not have a single quote in the first paramter (are you using an English keyboard and an ASCII programming editor and type the ' rather than copy/pasted it from somewhere) or your actual code after the str_replace() is adding a single quote. Here is the escape \ story one more time - The \ escape characters must be present in the query string so that special SQL characters, such as a single-quote, don't break the syntax of the query (or allow sql injection.) The \ characters are NOT inserted into the database. If you have \ characters in the database it means that your data was escaped twice. This usually happens if magic_quotes_gpc was ON at the time the data was inserted and your code also escaped the data. If the \ characters are not present in the database (which is correct) but they are present when the data is retrieved by php, that means that magic_quotes_runtime is on and it should simply be turned off in your script.
-
It's either not a single-quote or the first parameter in the str_replace() "'" is not a single-quote. What does this show, when put right after the line that sets $row - <?php $arr = str_split($row->name); foreach($arr as $char){ echo ord($char),'.'; } ?> Also, something unusual is going on with your database, because the \ escape character should not be present in the data in the database (though it could be in the data retrieved if magic_quotes_runtime is ON.)