-
Posts
16,734 -
Joined
-
Last visited
-
Days Won
9
Everything posted by PFMaBiSmAd
-
Invalid argument supplied for foreach() warning
PFMaBiSmAd replied to mallen's topic in PHP Coding Help
array_walk cannot be used with call-back functions that return values. It needs to be used with call-back functions that modify a value that is passed by reference. array_map works with a call-back function that return a value. -
That's because the size of the file is exceeding the post_max_size setting and the $_FILES and $_POST arrays are empty. To upload large files, you must increase the post_max_size and upload_max_filesize settings and you should be testing if a POST method form as been submitted and if the $_FILES and $_POST arrays are empty, to detect this condition and output an appropriate message to the user.
-
You typically update/create configuration files by writing the whole thing. Read/parse the existing settings into a php array. Set any of the array elements with values/new values, then write the whole config file based on that array of settings.
-
All of the $project[$n] needs to be just $project
-
The mail() function returns true if there is a sending mail server and it accepted the email without returning an error to php. That doesn't mean that the mail was actually sent. Since you are not setting the $header variable to anything, it's likely that the sending mail server doesn't know what to do with the email and isn't actually trying to send it. I would set the $header variable with a valid from address and the necessary headers for a html email. If you look in your document_root folder, you will find files named uploadssome_file.ext, because you missing a / between the upload directory name and the file name.
-
Your code was probably producing that Warning before, but it was being hidden by the error_reporting/display_errors settings on the previous server. However, your code, using the $n counter (what the Warning refers to) makes no sense. The foreach(){} loop is iterating over each of the $response['body']->project items. By referencing $project[$n]->status, where $n is incremented each pass through the foreach(){} loop, the first pass through the loop will reference $project[0]->status, the second pass through the loop (for the second $response['body']->project item) will reference $project[1]->status, then $project[2]->status, ... The Warning indicates that there is no $project[1]->status in the data under the second $response['body']->project item and if there is no warning message for higher values, that would indicate that there is only two $response['body']->project items in the data and the foreach(){} loop only loops two times. I suspect that your code appears to work because the first pass through the foreach(){} loop gets the correct data that you expect. What does the actual data source look like and what result do you expect from it and what result are you getting now, ignoring the Warning message?
-
Login Script failing with Internal Server Error 500.
PFMaBiSmAd replied to White_Lily's topic in PHP Coding Help
You need to look at the logic of your code. Your query is matching all the rows (no WHERE clause), then you retrieve/fetch the first row from the result set and test if the entered username/password matches that row. You need to use a WHERE clause in the query statement to try to find if the entered username/password matches a row in your table - WHERE username = '$log_user' AND password = '$log_pass'. You would then test how many rows the query matched to determine if the entered username/password was found in the table. -
In this case though, the problem is the 3rd most common reason for that error, you are reusing and overwriting the $r variable inside of your loop, so after the first pass through the loop, $r no longer contains the result resource from the outermost query. Its the result from the DELETE query, which will only be a true or false.
-
The output that is occurring on about line 20 of your file - if (strlen($instr) < 1000000) { is because that line is giving a warning message, that you apparently ignored and didn't tell us about - It's not just the last message that you get that is important. You are getting the error on line 20 because $instr is the file handle from the fopen() statement. It is not a string.
-
Login Script failing with Internal Server Error 500.
PFMaBiSmAd replied to White_Lily's topic in PHP Coding Help
You should be learning php, developing php code, and debugging php code on a local development system. By trying to use a live server for learning and development, you are wasting countless hours or your life that you will never get back by uploading your code each time to see the result of each change. Also, since code often contains security holes until it is complete and tested, by doing this on a live server you have a greater risk of a hacker taking over your web site. -
Login Script failing with Internal Server Error 500.
PFMaBiSmAd replied to White_Lily's topic in PHP Coding Help
1) You place a session_start() statement, before outputting anything to the browser, on any page that sets or references a $_SESSION variable. 2) You use $_SESSION variables and assign values to them - $_SESSION['log_user'] = $dbuser; or reference them - if(isset($_SESSION['log_user'])){...} Did you - -
Login Script failing with Internal Server Error 500.
PFMaBiSmAd replied to White_Lily's topic in PHP Coding Help
You may have tried something to get php to display and report errors, but it didn't work or it didn't work in the context of where you used it. We also cannot help you with what you tried unless you state or show what it is you did to turn those two settings on. The 500 http code means that the response sent out was incomplete. For a php page that generally means a fatal parse or runtime error. You cannot set php's error_reporting/display_errors settings in your script and have it show fatal parse errors in the main file because your script is never executed to turn on the settings. -
Mysql LIKE operator not working for safari
PFMaBiSmAd replied to NealeWeb's topic in PHP Coding Help
I'm going to guess that either the browser is requesting the page twice (different browsers do that for different reasons) and the second time it submits a $search term that causes all the results to be returned or that you actually have the posted query AND another query on the page that intentionally returns all the results and due to a logic error in your code, that only shows up for the one browser (due to a race condition or how the browser handles errors in the markup or how it handles redirects...), that the second query is executed and returns all the results. For problems like this - i.e. I have a page that doesn't work, it takes seeing and having all your code that reproduces the problem. The problem isn't the query (it is just doing what it is told to do), but either the data being put into the query or how many times that query (or another query on the page) is being executed. -
That's because the code that darkfreaks hacked up no longer tests if it was submitted to by the 'enter your email to reset your password' form that initially submits to that page and the code now incorrectly indicates that no email was entered when in fact that execution branch means that the entered email address (if any) wasn't found (the original error message your code had at that point was - "Invalid email address entered".)
-
Login Script failing with Internal Server Error 500.
PFMaBiSmAd replied to White_Lily's topic in PHP Coding Help
@floridaflatlander, You are mixing mysql_ (no i) and mysqli_ (with an i) statements. That won't work. -
Login Script failing with Internal Server Error 500.
PFMaBiSmAd replied to White_Lily's topic in PHP Coding Help
In case it has not already been suggested in one of your threads, when developing and debugging php code, you need to have php's error_reporting set to E_ALL and display_errors set to ON in your master php.ini on your development system so that php will report and display all the errors it detects. You will save a TON of time. Stop and start your web server to get any changes made to the master php.ini to take effect and confirm that the two settings actually got changed in case the php.ini that php is using is not the one that you changed. -
That's because the following line of code is nonsense - array_walk_recursive( $_POST, 'mysql_real_escape_string' ); The call-back function is passed the array value and array key as parameters one and two when it is called. Since the second parameter to the mysql_real_escape_string function is defined to be the optional connection link, it cannot be used in this way. The 'mysql_real_escape_string' function also isn't written to modify by reference the first parameter it is passed, so even if the second parameter wasn't an issue, none of the passed data values would get escaped.
-
It's generating a hash based on existing values in the database, rather than generating and storing a hash separately, so that when the password reset link is visited the hash from the link can be checked against the database information.
-
Hopefully, Michael's brother, Jackson Jackson isn't a student too, because that will match him. Also, their distant cousin Jackson Michael and his brother Michael Michael, and other first/last names that can be used as either - Martin Davis, Thomas Martin, Scott Thomas, ... I would concatenate the fields - CONCAT_WS(' ',firstname,lastname) = 'Michael Jackson'
-
Databases are for storing data (kind of why they are named what they are.) Code is not data. Why do you want to store php code in a database and then run that php code, given that this would be like giving a hacker an invitation to take over your web site.
-
Posting code with the short-comings fixed in it would do nothing toward finding out why the code is taking the execution path that gives an "Invalid email address entered." message. Some possibilities - 1) There's no database connection and php's error_reporting/display_errors are turned off while debugging so that php isn't helping find what might be failing when the code runs. 2) The database table name and/or column names are not correct or the database table field length isn't long enough to hold the data. 3) The field in the form that submits to the password reset code isn't using the field name that the code expects, which is why someone asked for the form code that initially submits to the password reset code. 4) The actual email address saved in the database table is different than the one being entered and/or some white-space is being included before/after the email address being entered (the password reset code isn't trimming the entered values before using them.)
-
You need to stick to one problem at a time and solve it before moving onto the next problem.
-
What's the code for the form with the emailaddress field in it that initially submits to that page?
-
Upon further review of your code, you are also missing the {} for the if(isset($_POST['search'])&&!empty($_POST['search'])){... ...} statement. Edit: And your html markup needs help. You are outputting multiple <html></html> tags (there's only one set per page) and you don't have all the content in the page inside of the one set of <html> ... ... </html> tags.
-
Your code has a do/while loop that it is deliberately running just once to output the table heading. There's no point in using any kind of loop around that table heading code since you would only want to output the table heading once. The while loop you kind of have around your code that displays the data from the query isn't constructed right. A while loop is - while(conditional statement){ statements that are executed inside the loop; ... } The {} delimit the code 'inside' the loop (yes, there's a special case with only one statement not needing the {}, but don't get in the habit of using php's lazy-way coding style) and there is no ; after the while(); (the one you have on the end of the while(); is actually terminating the while() loop on the line it is defined on.)